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.
This commit is contained in:
Wolfgang Walther 2025-05-28 15:31:14 +02:00
parent ea636d1728
commit a9b718b796
No known key found for this signature in database
GPG key ID: B39893FA5F65CAE1

View file

@ -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