Skip to content

Commit c490d2d

Browse files
authored
Merge pull request #36924: Fix linkage check script to handle detached HEAD state
2 parents 0fb3736 + fa1dad9 commit c490d2d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sdks/java/build-tools/beam-linkage-check.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ if [ ! -z "$(git diff)" ]; then
6969
exit 1
7070
fi
7171

72-
STARTING_REF=$(git rev-parse --abbrev-ref HEAD)
72+
# Use the full commit SHA instead of branch name to handle detached HEAD state.
73+
# This commonly happens when verifying someone else's PR, which involves
74+
# merging two non-branch references. See https://github.com/apache/beam/issues/20558
75+
STARTING_REF=$(git rev-parse HEAD)
7376
function cleanup() {
74-
git checkout $STARTING_REF
77+
git -c advice.detachedHead=false checkout $STARTING_REF
7578
}
7679
trap cleanup EXIT
7780

0 commit comments

Comments
 (0)