Skip to content

Commit 3e92f6b

Browse files
committed
pre-push: before pushing tags, need to be up to date with main
Since the same push might include not only the tag, but also the local `main` branch, and since the `pre-push` hook gets no information from Git _what_ is about to be pushed, the best we can do about `origin/main` is to _only_ warn if it is not up to date with the tag. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 3049866 commit 3e92f6b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pre-push.hook

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ do
2323
out="$(git tag --verify $tag 2>&1)" ||
2424
die "$out$LF${LF}Tag $tag is not signed/signature cannot be verified"
2525

26+
test 0 = $(git rev-list --count ...main) || die 'HEAD is not up to date with `main`'
27+
test 0 = $(git rev-list --count ...origin/main) ||
28+
echo 'warning: HEAD is not up to date with `origin/main`' >&2
29+
2630
regex="^ \"version\": \"$(echo "${tag#v}" | sed 's/\./\\./g')\",\$"
2731
substitute="s/^\\( \"version\": \"\\).*\",\$/\\1${tag#v}\",/"
2832
git grep -q "$regex" refs/tags/$tag -- package.json || {

0 commit comments

Comments
 (0)