From 2fea2bbf527ec30a62892f146d1a42305f7aa8f8 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 28 May 2025 12:48:30 +0200 Subject: [PATCH] ci/check-cherry-picks: support different remotes than "origin" The default is to checkout a contributors fork as "origin", thus the NixOS/nixpkgs remote is most likely named differently. But not everybody keeps their fork's main branches up-to-date all the time. Thus the script would fail locally. --- ci/check-cherry-picks.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ci/check-cherry-picks.sh b/ci/check-cherry-picks.sh index 9e12464526d2..44924ab8d8ab 100755 --- a/ci/check-cherry-picks.sh +++ b/ci/check-cherry-picks.sh @@ -14,6 +14,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")" PICKABLE_BRANCHES=${PICKABLE_BRANCHES:-master staging release-??.?? staging-??.??} problem=0 +# Not everyone calls their remote "origin" +remote="$(git remote -v | grep -i 'NixOS/nixpkgs' | head -n1 | cut -f1 || true)" + commits="$(git rev-list -E -i --grep="cherry.*[0-9a-f]{40}" --reverse "$1..$2")" while read -r new_commit_sha ; do @@ -40,10 +43,10 @@ while read -r new_commit_sha ; do fi set -f # prevent pathname expansion of patterns - for branch_pattern in $PICKABLE_BRANCHES ; do + for pattern in $PICKABLE_BRANCHES ; do set +f # re-enable pathname expansion - branches="$(git for-each-ref --format="%(refname)" "refs/remotes/origin/$branch_pattern")" + branches="$(git for-each-ref --format="%(refname)" "refs/remotes/${remote:-origin}/$pattern")" while read -r picked_branch ; do if git merge-base --is-ancestor "$original_commit_sha" "$picked_branch" ; then