Skip to content

Commit 24a9df3

Browse files
Fix release branch resolution picking stale feature branches
git branch -r --contains matches any branch that has the tag commit as an ancestor, not just the branch it was cut from. Long-lived or merged branches keep that ancestry indefinitely, so alphabetical head -n 1 could select the wrong branch (e.g. a stale feature branch instead of main), which then made the checkout in the Commit changes step collide with the uncommitted pom.xml version bump. Switch to git for-each-ref --points-at to match only the branch whose tip is exactly the tag commit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 93456df commit 24a9df3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

.github/workflows/shared-build-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }}
6868
run: |
6969
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})
70-
BRANCH_NAME=$(git branch -r --contains $TAG_COMMIT | grep -o 'origin/.*' | sed 's|origin/||' | head -n 1)
70+
BRANCH_NAME=$(git for-each-ref --points-at="$TAG_COMMIT" --format='%(refname:short)' refs/remotes/origin | grep -v '/HEAD$' | sed 's#^origin/##' | head -n 1)
7171
if [ -z "$BRANCH_NAME" ]; then
7272
echo "Error: Could not resolve branch for the tag."
7373
exit 1

0 commit comments

Comments
 (0)