summaryrefslogtreecommitdiff
path: root/tools/prepare-commit-msg
diff options
context:
space:
mode:
authorAlexis Hildebrandt <afh@surryhill.net>2015-01-23 16:13:54 +0100
committerAlexis Hildebrandt <afh@surryhill.net>2015-01-23 16:20:39 +0100
commit2d45bd8c258510a3ccffccae1f72e062b7203664 (patch)
tree1cee103948648ca4fa539509381205dd37637812 /tools/prepare-commit-msg
parent2030240849a1a3c14b54428fb2f73c662e62d4a4 (diff)
downloadfork-ledger-2d45bd8c258510a3ccffccae1f72e062b7203664.tar.gz
fork-ledger-2d45bd8c258510a3ccffccae1f72e062b7203664.tar.bz2
fork-ledger-2d45bd8c258510a3ccffccae1f72e062b7203664.zip
[tools] Improve prepare git commit message hook
by ignoring merge commits and commits with a message already containing `[ci skip]`.
Diffstat (limited to 'tools/prepare-commit-msg')
-rwxr-xr-xtools/prepare-commit-msg15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg
index e103888a..ab351760 100755
--- a/tools/prepare-commit-msg
+++ b/tools/prepare-commit-msg
@@ -8,6 +8,12 @@
function add_ci_skip()
{
pattern="$1"; shift
+ source="$1"
+
+ # Don't add [ci skip] if it's already in the commit message source
+ grep '\[ci skip\]' "$source" 2>&1 >/dev/null
+ [ $? -eq 0 ] && return
+
if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then
tempfile=$(mktemp $0.XXXXXX)
cat - "$1" <<EOF > "$tempfile"
@@ -19,9 +25,14 @@ function add_ci_skip()
# comment or remove the next line.
[ci skip]
EOF
- mv "$tempfile" "$1"
+ mv "$tempfile" "$source"
fi
}
## MAIN
-add_ci_skip '\(^src\|^test\|^doc/ledger3.texi\|^\.travis.yml\|CMakeLists.txt\)' "$@"
+file="$1"
+source="$2"
+
+# Skip merge commits
+[ "$source" = "merge" ] && exit 0
+add_ci_skip '\(^src\|^test\|^doc/ledger3.texi\|^\.travis.yml\|CMakeLists.txt\)' "$file"