diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-29 19:16:21 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-29 19:16:21 +1200 |
commit | a576ef69527afea228c7362b36e999da0c50a86b (patch) | |
tree | 1db42eb279c8e5c04061e38757bd13d8dc9674e0 | |
parent | Merge branch 'release/v5.7.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-a576ef69527afea228c7362b36e999da0c50a86b.tar.gz dotfiles-a576ef69527afea228c7362b36e999da0c50a86b.zip |
Merge branch 'release/v5.8.0'v5.8.0
* release/v5.8.0:
Add pre-commit hook
Remove execute bit from Git hook source
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | IDEAS.md | 3 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | git/template/hooks/pre-commit.sh | 12 | ||||
-rw-r--r--[-rwxr-xr-x] | git/template/hooks/prepare-commit-msg.awk | 0 |
6 files changed, 16 insertions, 5 deletions
@@ -170,6 +170,7 @@ /games/zs /git/gitconfig /git/gitconfig.m4 +/git/template/hooks/pre-commit /git/template/hooks/prepare-commit-msg /git/template/hooks/post-update /gnupg/gpg.conf @@ -32,8 +32,5 @@ Ideas * Write a ftplugin for Perl to switch between punctuation variable names and English variable names., i.e. \e on `$?` would change to `$CHILD_ERROR`, and vice-versa. -* Could probably put my pre-commit hook that bans commits to master in here; - maybe make it a bit smarter by only banning commits to master if a branch - named "develop" exists * Almost definitely going to want to try a runparts layout for Git hooks at some point @@ -264,6 +264,7 @@ GAMES = games/aaf \ games/zs GIT_TEMPLATE_HOOKS = git/template/hooks/post-update \ + git/template/hooks/pre-commit \ git/template/hooks/prepare-commit-msg all: $(BINS) git/gitconfig $(GIT_TEMPLATE_HOOKS) gnupg/gpg.conf @@ -1,2 +1,2 @@ -tejr dotfiles v5.7.0 -Wed May 29 18:15:54 NZST 2019 +tejr dotfiles v5.8.0 +Wed May 29 07:16:21 UTC 2019 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 diff --git a/git/template/hooks/prepare-commit-msg.awk b/git/template/hooks/prepare-commit-msg.awk index 2fe43c5b..2fe43c5b 100755..100644 --- a/git/template/hooks/prepare-commit-msg.awk +++ b/git/template/hooks/prepare-commit-msg.awk |