forked from ledger/ledger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add git hook to skip continous integration
if the commit is not related to code under test. [ci skip]
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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\)' "$@" |