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
This commit is contained in:
peaklabs-dev
2026-11-02 16:50:05 +01:00
parent 697d559c7c
commit 2b4a4bff08
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -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"
+6 -2
View File
@@ -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"