Skip to content

Commit

Permalink
git: Add pre-push hook for catching accidental versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechampine committed Feb 6, 2020
1 parent ba0669a commit 6e507af
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pre-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# A pre-push hook to prevent accidentally pushing new major versions.

vs="$(git tag | sort -rV | cut -c 1,2 | head -n 2)"
if [[ "$(echo "$vs" | wc -l | awk '{print $1}')" == "2" ]] && [[ -z $(echo "$vs" | uniq -d) ]]; then
echo >&2 "It looks like you're pushing a tag with a new major version!"
echo >&2 "...I'm gonna assume that was a mistake."
echo >&2 "If it wasn't, just rm this hook before pushing again."
exit 1;
fi

0 comments on commit 6e507af

Please sign in to comment.