diff options
author | 2011-03-01 20:17:59 -0500 | |
---|---|---|
committer | 2011-03-01 20:59:04 -0500 | |
commit | c489b189df39c75195f85ab26afe08cd44ad7f2e (patch) | |
tree | b64b2009dccf56c5d5ebf1b5a6a973f9ffc7ec4d /git-tools | |
parent | [ticket/9824] Add space after [ticket/12345] in prepared commit message. (diff) | |
download | phpbb-c489b189df39c75195f85ab26afe08cd44ad7f2e.tar.gz phpbb-c489b189df39c75195f85ab26afe08cd44ad7f2e.tar.bz2 phpbb-c489b189df39c75195f85ab26afe08cd44ad7f2e.zip |
[ticket/9824] Handle empty commit messages in commit-msg hook.
Git already handles the case of commit message being empty by
aborting the commit and displaying a reasonably helpful message.
If there is no commit message, the hook will exit with success
exit code to let git do its thing.
PHPBB3-9824
Diffstat (limited to 'git-tools')
-rwxr-xr-x | git-tools/hooks/commit-msg | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg index a6777ff9c9..1d33995162 100755 --- a/git-tools/hooks/commit-msg +++ b/git-tools/hooks/commit-msg @@ -55,6 +55,17 @@ quit() fi } +# Check for empty commit message +if ! grep -qv '^#' "$1" +then + # Commit message is empty (or contains only comments). + # Let git handle this. + # It will abort with a message like so: + # + # Aborting commit due to empty commit message. + exit 0 +fi + msg=$(grep -nE '.{81,}' "$1"); if [ $? -eq 0 ] |