Skip to content

Commit

Permalink
pre-push: before pushing tags, need to be up to date with main
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dscho committed Jan 14, 2022
1 parent 3049866 commit 3e92f6b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pre-push.hook
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ do
out="$(git tag --verify $tag 2>&1)" ||
die "$out$LF${LF}Tag $tag is not signed/signature cannot be verified"

test 0 = $(git rev-list --count ...main) || die 'HEAD is not up to date with `main`'
test 0 = $(git rev-list --count ...origin/main) ||
echo 'warning: HEAD is not up to date with `origin/main`' >&2

regex="^ \"version\": \"$(echo "${tag#v}" | sed 's/\./\\./g')\",\$"
substitute="s/^\\( \"version\": \"\\).*\",\$/\\1${tag#v}\",/"
git grep -q "$regex" refs/tags/$tag -- package.json || {
Expand Down

0 comments on commit 3e92f6b

Please sign in to comment.