From a9b718b79640e9c0ad4366391654fd4138248187 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 28 May 2025 15:31:14 +0200 Subject: [PATCH] ci/check-cherry-picks: never check older stable branches This makes the job significantly faster when the commit can't be found on master or staging directly. Before this change, the script would have had to iterate through 20+ release branches before finding the latest one. With lazy fetching for git enabled, this would take a few minutes. --- ci/check-cherry-picks.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ci/check-cherry-picks.sh b/ci/check-cherry-picks.sh index 2d1e6eb7c03c..0ef8ff904f4a 100755 --- a/ci/check-cherry-picks.sh +++ b/ci/check-cherry-picks.sh @@ -46,7 +46,14 @@ while read -r new_commit_sha ; do for pattern in $PICKABLE_BRANCHES ; do set +f # re-enable pathname expansion - branches="$(git for-each-ref --format="%(refname)" "refs/remotes/${remote:-origin}/$pattern")" + # Reverse sorting by refname and taking one match only means we can only backport + # from unstable and the latest stable. That makes sense, because even right after + # branch-off, when we have two supported stable branches, we only ever want to cherry-pick + # **to** the older one, but never **from** it. + # This makes the job significantly faster in the case when commits can't be found, + # because it doesn't need to iterate through 20+ branches, which all need to be fetched. + branches="$(git for-each-ref --sort=-refname --format="%(refname)" \ + "refs/remotes/${remote:-origin}/$pattern" | head -n1)" while read -r picked_branch ; do if git merge-base --is-ancestor "$original_commit_sha" "$picked_branch" ; then