diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-29 19:15:51 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-29 19:16:02 +1200 |
commit | 39ccc7147bdef51db39e5b59541a5dc1248190ee (patch) | |
tree | b2242134af0fbed18c9d283773300009aacc9a48 /git | |
parent | Remove execute bit from Git hook source (diff) | |
download | dotfiles-39ccc7147bdef51db39e5b59541a5dc1248190ee.tar.gz dotfiles-39ccc7147bdef51db39e5b59541a5dc1248190ee.zip |
Add pre-commit hook
Diffstat (limited to 'git')
-rw-r--r-- | git/template/hooks/pre-commit.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/git/template/hooks/pre-commit.sh b/git/template/hooks/pre-commit.sh new file mode 100644 index 00000000..22e876ad --- /dev/null +++ b/git/template/hooks/pre-commit.sh @@ -0,0 +1,12 @@ +# Reject a commit directly to a branch named 'master' if a branch named +# 'develop' exists + +# Allow commit if it's not to master +[ "$(git rev-parse --abbrev-ref HEAD)" = master ] || exit 0 + +# Allow commit if there's no develop branch +git show-ref --quiet --verify refs/heads/develop || exit 0 + +# Throw toys +printf >&2 'Branch develop exists, commits to master blocked\n' +exit 1 |