소스 검색

prep commit msg hook: prepend msg of previous commit

Fabian Peter Hammerle 6 년 전
부모
커밋
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"