Skip to content

Commit cdb2366

Browse files
committed
pre-push: before pushing tags, ensure correct version in package.json
So far, this maintainer totally forgot to increment it. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 6eaeea1 commit cdb2366

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pre-push.hook

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ die () {
1212
git diff --no-index --quiet pre-push.hook "$(git rev-parse --git-path hooks/pre-push)" ||
1313
die 'The `pre-push` hook is not up to date with `pre-push.hook`'
1414

15+
# Verify that any tagged version is reflected in its `package.json`
16+
for tag in $(git for-each-ref --format='%(refname:short)' --points-at=HEAD 'refs/tags/v[0-9]*')
17+
do
18+
git grep -q '"version": "'"${tag#v}"'"' refs/tags/$tag -- package.json || {
19+
sed 's/\("version": "\)[^"]*/\1'"${tag#v}"/ <package.json >package.json.new &&
20+
mv -f package.json.new package.json
21+
die "package.json did not reflect $tag; It was adjusted."
22+
exit 1
23+
}
24+
done
25+
1526
git diff --quiet dist/ ||
1627
die '`dist/` is dirty'
1728

0 commit comments

Comments
 (0)