Commit af2cec6d authored by xuwang's avatar xuwang
Browse files

fix(release): compare HEAD to FETCH_HEAD, not the tracking ref



An explicit-refspec fetch (git fetch origin main) updates FETCH_HEAD but
can leave refs/remotes/origin/main stale, so the sync guard added in the
previous commit would falsely report divergence and block every release.
Compare against FETCH_HEAD, which always reflects the just-fetched tip.

Co-Authored-By: default avatarClaude Opus 4.8 <noreply@anthropic.com>
parent cb76b44b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -41,8 +41,10 @@ git remote get-url "${REMOTE}" >/dev/null 2>&1 || err "git remote '${REMOTE}' no
# Changelog notes are rendered server-side over (latest_tag .. RELEASE_BRANCH]
# via the GitLab API, so local ${RELEASE_BRANCH} must match the remote — else
# unpushed Changelog-trailer commits land in the tag but not in CHANGELOG.md.
# Compare against FETCH_HEAD, not refs/remotes/${REMOTE}/${RELEASE_BRANCH}: an
# explicit-refspec fetch updates FETCH_HEAD but may leave the tracking ref stale.
git fetch -q "${REMOTE}" "${RELEASE_BRANCH}" || err "Failed to fetch ${REMOTE}/${RELEASE_BRANCH}."
[ "$(git rev-parse HEAD)" = "$(git rev-parse "${REMOTE}/${RELEASE_BRANCH}")" ] \
[ "$(git rev-parse HEAD)" = "$(git rev-parse FETCH_HEAD)" ] \
    || err "Local ${RELEASE_BRANCH} differs from ${REMOTE}/${RELEASE_BRANCH}. Push or pull first."

if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then