From e0038e9420b7022a25098f63779c1d8d5a137da0 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 5 Apr 2017 16:34:29 +1000 Subject: [PATCH] Replace the post-commit hook with a commit-msg hook that does the same thing (but that avoids needing to amend every commit :3 ) --- config/git/hooks/commit-msg | 20 ++++++++++++++++++++ config/git/hooks/post-commit | 11 ----------- 2 files changed, 20 insertions(+), 11 deletions(-) create mode 100755 config/git/hooks/commit-msg delete mode 100755 config/git/hooks/post-commit diff --git a/config/git/hooks/commit-msg b/config/git/hooks/commit-msg new file mode 100755 index 0000000..2e2f646 --- /dev/null +++ b/config/git/hooks/commit-msg @@ -0,0 +1,20 @@ +#!/bin/sh +echo >> $1 + +echo Calculating git guilt... >&2 +# git-guilt only works on actual commits, not on the index. Fortunately we can +# create a temporary commit for git-guilt to look at, using git-stash! +git stash save -q + +# stash@{0}^2 is the index. I know, it's weird. We call git-guilt twice because +# we want the nice colours when we commit in a terminal, but we don't want them +# in the actual commit message. +git guilt HEAD stash@{0}^2 >&2 +git guilt HEAD stash@{0}^2 >> $1 + +# Now restore the changes from stash, so we can actually commit them. ;) +git stash pop -q --index + +echo >> $1 +echo Fetching a whatthecommit message... >&2 +curl -s http://whatthecommit.com/index.txt | tee -a $1 >&2 diff --git a/config/git/hooks/post-commit b/config/git/hooks/post-commit deleted file mode 100755 index 6468f60..0000000 --- a/config/git/hooks/post-commit +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env zsh - -chmod a-x $0 - -msg="$(git log -n 1 --pretty=format:'%s%n%n%b')" -guilt="$(git guilt HEAD~1 HEAD)" -what="$(curl http://whatthecommit.com/index.txt)" - -git commit --no-verify --amend -m $msg$'\n\n'$guilt$'\n\n'$what - -chmod a+x $0