aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-29 19:16:21 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-29 19:16:21 +1200
commita576ef69527afea228c7362b36e999da0c50a86b (patch)
tree1db42eb279c8e5c04061e38757bd13d8dc9674e0
parentMerge branch 'release/v5.7.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-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--.gitignore1
-rw-r--r--IDEAS.md3
-rw-r--r--Makefile1
-rw-r--r--VERSION4
-rw-r--r--git/template/hooks/pre-commit.sh12
-rw-r--r--[-rwxr-xr-x]git/template/hooks/prepare-commit-msg.awk0
6 files changed, 16 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 23074970..67cae516 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/IDEAS.md b/IDEAS.md
index 968065b1..adbc1d59 100644
--- a/IDEAS.md
+++ b/IDEAS.md
@@ -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
diff --git a/Makefile b/Makefile
index 6612a5d3..a9f03e41 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/VERSION b/VERSION
index 8a5ce1cc..bf41501b 100644
--- a/VERSION
+++ b/VERSION
@@ -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