| 1 | #!/bin/shscip-shell filesystem . . `/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_skipscip-shell shell shell-project 0.0.0 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 | grepscip-shell system . . grep. '\[ci skip\]' "$source" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 15 | [scip-shell system . . `[`. $? -eq 0 ] && return |
| 16 | |
| 17 | if [scip-shell system . . `[`. $(gitscip-shell system . . git. diff --cached --name-only | grepscip-shell system . . grep. --count "$pattern") -eq 0 ]; then |
| 18 | tempfile=$(mktempscip-shell system . . mktemp. "${0}.XXXXXX") |
| 19 | catscip-shell system . . 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 | mvscip-shell system . . mv. "$tempfile" "$source" |
| 29 | fi |
| 30 | } |
| 31 | |
| 32 | ## MAIN |
| 33 | file="$1" |
| 34 | source="$2" |
| 35 | |
| 36 | # Skip merge commits |
| 37 | [scip-shell system . . `[`. "$source" = "merge" ] && exit 0 |
| 38 | add_ci_skipscip-shell shell shell-project 0.0.0 add_ci_skip(). '\(^src\|^test\|^doc/ledger3.texi\|^\.travis.yml\|CMakeLists.txt\)' "$file" |