From 2b4a4bff0820b2c6e76453ded7cac5c34c315338 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 2 Nov 2026 16:50:05 +0100 Subject: [PATCH] fix(release): name the local tags that differ from origin - a local tag that differs from origin, such as a tag moved on origin before the tag protection rule, failed the fetch with "could not fetch origin" and no reason, as --quiet also hid the rejected tags --- scripts/plan-version.sh | 8 ++++++-- scripts/release.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/plan-version.sh b/scripts/plan-version.sh index c93efa9e3d..74528857a7 100755 --- a/scripts/plan-version.sh +++ b/scripts/plan-version.sh @@ -64,9 +64,13 @@ print_build_version() { } fetch_origin() { - local current behind + local current behind fetched stale [ "$(git rev-parse --is-shallow-repository)" = false ] || die "the clone is shallow, run git fetch --unshallow first" - git fetch --quiet --prune --tags origin || die "could not fetch origin" + fetched="$(git fetch --porcelain --no-progress --prune --tags origin)" || { + stale="$(awk '$1 == "!" { sub("^refs/tags/", "", $4); print $4 }' <<< "$fetched" | paste -sd ' ' -)" + [ -z "$stale" ] || die "the local tag(s) $stale differ from origin, check them with git ls-remote --tags origin, then run git fetch --tags --force origin" + die "could not fetch origin" + } current="$(git branch --show-current)" if [ -n "$current" ] && behind="$(git rev-list --count "HEAD..origin/$current" 2> /dev/null)"; then [ "$behind" = 0 ] || die "$current is $behind commit(s) behind origin/$current, pull first" diff --git a/scripts/release.sh b/scripts/release.sh index 79e19e8df8..1f8f3f243c 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -44,7 +44,7 @@ main() { } check_repository() { - local counts behind ahead entries + local counts behind ahead entries fetched stale heading "Checking the repository" git rev-parse --is-inside-work-tree > /dev/null 2>&1 || die "$PWD is not a git repository" branch="$(git symbolic-ref --quiet --short HEAD)" || die "HEAD is detached, expected a branch" @@ -55,7 +55,11 @@ check_repository() { [[ ! "$branch" =~ ^(next|release/) ]] || channel=preview [ -z "$(git status --porcelain)" ] || die "the working tree is not clean, commit or stash first" [ "$(git rev-parse --is-shallow-repository)" = false ] || die "the clone is shallow, run git fetch --unshallow first" - git fetch --quiet --prune --tags origin || die "could not fetch origin" + fetched="$(git fetch --porcelain --no-progress --prune --tags origin)" || { + stale="$(awk '$1 == "!" { sub("^refs/tags/", "", $4); print $4 }' <<< "$fetched" | paste -sd ' ' -)" + [ -z "$stale" ] || die "the local tag(s) $stale differ from origin, check them with git ls-remote --tags origin, then run git fetch --tags --force origin" + die "could not fetch origin" + } counts="$(git rev-list --left-right --count "origin/$branch...HEAD" 2> /dev/null)" || die "origin has no branch $branch, push it first" read -r behind ahead <<< "$counts" [ "$behind$ahead" = 00 ] || die "$branch is $ahead commit(s) ahead of and $behind behind origin/$branch, expected it in sync"