瀏覽代碼

prep commit msg hook: prepend msg of previous commit

Fabian Peter Hammerle 5 年之前
父節點
當前提交
72c688fa6f
共有 2 個文件被更改,包括 13 次插入0 次删除
  1. 1 0
      gitconfig
  2. 12 0
      hooks/prepare-commit-msg

+ 1 - 0
gitconfig

@@ -5,6 +5,7 @@
 
 [core]
 	excludesfile = ~/.config/git/gitignore
+	hooksPath = ~/.config/git/hooks
 
 [interactive]
 	singleKey = true

+ 12 - 0
hooks/prepare-commit-msg

@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -x
+
+MSG_PATH=$1
+
+TMP_PATH="$(mktemp)"
+
+git log --format='%B' -1 | sed 's/^/#/' >> "$TMP_PATH"
+cat "$MSG_PATH" >> "$TMP_PATH"
+
+mv "$TMP_PATH" "$MSG_PATH"