summary refs log tree commit diff
path: root/githooks
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-06-19 16:23:53 +0000
committeredef <edef@unfathomable.blue>2022-06-19 16:56:42 +0000
commitc92e98b0847a917a7e436ef738eebb93f51e5de8 (patch)
tree509c102e5e00ab622180fd8a747d95430ad3d4bf /githooks
parent2ce27876db9b8a391bbb91aceba57dc99271dab0 (diff)
githooks/commit-msg: don't inhibit git's empty commit message behaviour
Change-Id: I9e800f347cfb5440c384766f0be55aba4a40c94f
Diffstat (limited to 'githooks')
-rwxr-xr-xgithooks/commit-msg6
1 files changed, 6 insertions, 0 deletions
diff --git a/githooks/commit-msg b/githooks/commit-msg
index d241f2b..c4c7736 100755
--- a/githooks/commit-msg
+++ b/githooks/commit-msg
@@ -2,6 +2,12 @@
 set -euo pipefail
 change_id=$(head -c32 /dev/urandom | git hash-object --stdin)
 
+cut_line='------------------------ >8 ------------------------'
+if [ $(< "$1" sed -e "/^# ${cut_line}$/Q" | git stripspace --strip-comments | wc -c) -eq 0 ]; then
+    # don't inhibit "Aborting commit due to empty commit message"
+    exit 0
+fi
+
 git interpret-trailers \
     --if-exists doNothing \
     --trailer "Change-Id:I$change_id" \