1313'
1414
1515git diff --no-index --quiet pre-push.hook " $( git rev-parse --git-path hooks/pre-push) " ||
16- die ' The `pre-push` hook is not up to date with `pre-push.hook`'
16+ die ' The `pre-push` hook is not up to date with `pre-push.hook`. Please update:
17+
18+ cp pre-push.hook .git/hooks/pre-push'
1719
1820# Verify that any tagged version is reflected in its `package.json`
1921for tag in $( git for-each-ref --format=' %(refname:short)' --points-at=HEAD ' refs/tags/v[0-9]*' )
2022do
2123 out=" $( git tag --verify $tag 2>&1 ) " ||
2224 die " $out$LF ${LF} Tag $tag is not signed/signature cannot be verified"
2325
24- git grep -q ' "version": "' " ${tag# v} " ' "' refs/tags/$tag -- package.json || {
25- sed ' s/\("version": "\)[^"]*/\1' " ${tag# v} " / < package.json > package.json.new &&
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+
30+ regex=" ^ \" version\" : \" $( echo " ${tag# v} " | sed ' s/\./\\./g' ) \" ,\$ "
31+ substitute=" /\" name\" : \" rss-to-issues\" /{N;s/\\ (\" version\" : \"\\ ).*\" ,\$ /\\ 1${tag# v} \" ,/}"
32+ git grep -q " $regex " refs/tags/$tag -- package.json || {
33+ sed " $substitute " < package.json > package.json.new &&
2634 mv -f package.json.new package.json
35+ sed " $substitute " < package-lock.json > package-lock.json.new &&
36+ mv -f package-lock.json.new package-lock.json
2737 die " package.json did not reflect $tag ; It was adjusted."
2838 exit 1
2939 }
40+
41+ git grep -q " $regex " refs/tags/$tag -- package-lock.json || {
42+ sed " $substitute " < package-lock.json > package-lock.json.new &&
43+ mv -f package-lock.json.new package-lock.json
44+ die " package-lock.json did not reflect $tag ; It was adjusted."
45+ exit 1
46+ }
3047done
3148
3249git diff --quiet dist/ ||
4259 echo " Committing dist/ because it was not up to date" >&2
4360 git commit -sm " npm run prepare" dist/
4461 fi
45- fi
62+ fi
0 commit comments