| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Prepare git commit message: |
| 4 |
# - Add [ci skip] if the changes seem irrelevant for continuous integration |
| 5 |
|
| 6 |
# Add [ci skip] to the commit message unless there are changes to files |
| 7 |
# that are relevant for testing such as src/*, test/*, ledger3.texi, ... |
| 8 |
add_ci_skip () |
| 9 |
{ |
| 10 |
pattern="$1"; shift |
| 11 |
source="$1" |
| 12 |
|
| 13 |
# Don't add [ci skip] if it's already in the commit message source |
| 14 |
grep '\[ci skip\]' "$source" >/dev/null 2>&1 |
| 15 |
[ $? -eq 0 ] && return |
| 16 |
|
| 17 |
if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then |
| 18 |
tempfile=$(mktemp "${0}.XXXXXX") |
| 19 |
cat - "$1" <<EOF > "$tempfile" |
| 20 |
|
| 21 |
# It seems the changes to be committed are irrelevant for the continuous |
| 22 |
# integration, therefore it will be skipped for this commit. |
| 23 |
# |
| 24 |
# If you still want continuous integration to run for this commit |
| 25 |
# comment or remove the next line. |
| 26 |
[ci skip] |
| 27 |
EOF |
| 28 |
mv "$tempfile" "$source" |
| 29 |
fi |
| 30 |
} |
| 31 |
|
| 32 |
## MAIN |
| 33 |
file="$1" |
| 34 |
source="$2" |
| 35 |
|
| 36 |
# Skip merge commits |
| 37 |
[ "$source" = "merge" ] && exit 0 |
| 38 |
add_ci_skip '\(^src\|^test\|^doc/ledger3.texi\|^\.travis.yml\|CMakeLists.txt\)' "$file" |