Fix release destination handling and verification example

This commit is contained in:
2026-09-28 01:42:06 +00:00
parent d750e7325c
commit a36ed3deba
4 changed files with 69 additions and 7 deletions

View File

@@ -36,7 +36,7 @@ check_unused_version() {
read_remote_ref() {
local ref=$1 response result
if response=$(git ls-remote --refs --exit-code "$remote_url" "$ref" 2>/dev/null); then
if response=$(git ls-remote --refs --exit-code origin "$ref" 2>/dev/null); then
[[ "$response" == *$'\t'"$ref" ]] || return 3
printf '%s\n' "${response%%$'\t'*}"
else
@@ -78,7 +78,7 @@ else
((result == 2)) && fail "authoritative main is absent"
fail "cannot read authoritative main; publication status is unknown"
fi
git fetch --no-tags "$remote_url" refs/heads/main >/dev/null ||
git fetch --no-tags origin refs/heads/main >/dev/null ||
fail "cannot fetch authoritative main"
fetched_main=$(git rev-parse --verify FETCH_HEAD) || fail "cannot inspect fetched main"
git merge-base --is-ancestor "$fetched_main" "$candidate" ||
@@ -88,7 +88,10 @@ git merge-base --is-ancestor "$fetched_main" "$candidate" ||
check_candidate "after validation"
check_unused_version
if git push --no-follow-tags "$remote_url" "$candidate:refs/heads/main"; then
# Use the named remote whose resolved destinations were checked above: a literal
# URL can apply pushInsteadOf even when origin's explicit push URL does not.
# Disable mirror defaults as well as implicit tags; publish only our refspec.
if git -c remote.origin.mirror=false push --no-follow-tags origin "$candidate:refs/heads/main"; then
:
else
if observed_main=$(read_remote_ref refs/heads/main); then
@@ -113,7 +116,7 @@ tag_type=$(git cat-file -t "refs/tags/$version") ||
tag_oid=$(git rev-parse --verify "refs/tags/$version") ||
fail "main is at $candidate; cannot identify local tag $version"
if git push --no-follow-tags "$remote_url" "refs/tags/$version:refs/tags/$version"; then
if git -c remote.origin.mirror=false push --no-follow-tags origin "refs/tags/$version:refs/tags/$version"; then
:
else
if observed_tag=$(read_remote_ref "refs/tags/$version"); then