From 1522a382e00118c872b9eeb8b0a533fbc8d618f8 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 21 Dec 2014 20:54:01 +0100 Subject: Add git hook to skip continous integration if the commit is not related to code under test. [ci skip] --- tools/prepare-commit-msg | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tools/prepare-commit-msg (limited to 'tools') 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" < "$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\)' "$@" -- cgit v1.2.3 From b800cfc41883570794b824e2306ac71fb84e2f8c Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 24 Dec 2014 11:00:05 +0100 Subject: [travis] Run Travis build when .travis.yml changed - Change match pattern to include ^\.travis.yml - Add executable file permissions for tools/prepare-commit-msg [ci skip] --- tools/prepare-commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 tools/prepare-commit-msg (limited to 'tools') diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg old mode 100644 new mode 100755 index c943fa2b..e103888a --- a/tools/prepare-commit-msg +++ b/tools/prepare-commit-msg @@ -24,4 +24,4 @@ EOF } ## MAIN -add_ci_skip '\(^src\|^test\|^doc/ledger3.texi\|CMakeLists.txt\)' "$@" +add_ci_skip '\(^src\|^test\|^doc/ledger3.texi\|^\.travis.yml\|CMakeLists.txt\)' "$@" -- cgit v1.2.3