diff --git a/batch-change/release.yaml b/batch-change/release.yaml index 2534f0a07..22ef5f1ec 100644 --- a/batch-change/release.yaml +++ b/batch-change/release.yaml @@ -136,9 +136,18 @@ promoteToPublic: # Create the final branch holding the tagged commit git checkout "${promote_branch}" - git switch -c "${release_branch}" - - git tag {{version}} + git switch -C "${release_branch}" + + # A retried finalize finds its own tag; only a tag elsewhere is an error + if tagged=$(git rev-parse -q --verify "refs/tags/{{version}}^{commit}"); then + if [ "${tagged}" != "$(git rev-parse HEAD)" ]; then + echo "Tag {{version}} already exists at ${tagged}, not at ${promote_branch} ($(git rev-parse HEAD))" >&2 + exit 1 + fi + echo "Tag {{version}} already points at ${promote_branch}, not recreating it" + else + git tag {{version}} + fi git push origin ${release_branch} --tags # Web URL to the tag diff --git a/release.yaml b/release.yaml index 83206ff7d..6d40af394 100644 --- a/release.yaml +++ b/release.yaml @@ -199,7 +199,7 @@ promoteToPublic: # Create the final branch holding the tagged commit git checkout "${promote_branch}" - git switch -c "${release_branch}" + git switch -C "${release_branch}" # A retried finalize finds its own tag; only a tag elsewhere is an error if tagged=$(git rev-parse -q --verify "refs/tags/{{version}}^{commit}"); then