summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlexis Hildebrandt <afh@surryhill.net>2014-12-21 20:54:01 +0100
committerAlexis Hildebrandt <afh@surryhill.net>2014-12-21 20:54:01 +0100
commit1522a382e00118c872b9eeb8b0a533fbc8d618f8 (patch)
tree617bcb007b5e856fa6c290b5a1cf88a1ddbe78a8 /tools
parent5fea9c9b024c540bceffe50822f726722f3fe6a1 (diff)
downloadfork-ledger-1522a382e00118c872b9eeb8b0a533fbc8d618f8.tar.gz
fork-ledger-1522a382e00118c872b9eeb8b0a533fbc8d618f8.tar.bz2
fork-ledger-1522a382e00118c872b9eeb8b0a533fbc8d618f8.zip
Add git hook to skip continous integration
if the commit is not related to code under test. [ci skip]
Diffstat (limited to 'tools')
-rw-r--r--tools/prepare-commit-msg27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg
new file mode 100644
index 00000000..c943fa2b
--- /dev/null
+++ b/tools/prepare-commit-msg
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Prepare git commit message:
+# - Add [ci skip] if the changes seem irrelevant for continuous integration
+
+# Add [ci skip] to the commit message unless there are changes to files
+# that are relevant for testing such as src/*, test/*, ledger3.texi, ...
+function add_ci_skip()
+{
+ pattern="$1"; shift
+ if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then
+ tempfile=$(mktemp $0.XXXXXX)
+ cat - "$1" <<EOF > "$tempfile"
+
+# It seems the changes to be committed are irrelevant for the continuous
+# integration, therefore it will be skipped for this commit.
+#
+# If you still want continuous integration to run for this commit
+# comment or remove the next line.
+[ci skip]
+EOF
+ mv "$tempfile" "$1"
+ fi
+}
+
+## MAIN
+add_ci_skip '\(^src\|^test\|^doc/ledger3.texi\|CMakeLists.txt\)' "$@"