From 17f67ae625bcbca5fc87ff3fb81c24ab449f2962 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 16 Mar 2017 18:50:48 +0100 Subject: [PATCH] Added githook to skip CI build on non-src changes --- .githooks/commit-msg/skip.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.githooks/commit-msg/skip.sh b/.githooks/commit-msg/skip.sh index 76d952d53..36059f92a 100755 --- a/.githooks/commit-msg/skip.sh +++ b/.githooks/commit-msg/skip.sh @@ -28,27 +28,27 @@ fi # Filter relevant files for linting FILES=$(git diff --cached --name-only) -# Load the patterns we want to skip into an array -mapfile -t BLACKLIST < .travisignore +# Resolve the patterns we want to skip +BLACKLIST=$(< .travisignore) # Remove the pattern from the list of changes -for $pattern in "${BLACKLIST[@]}"; do - CHANGES=( ${CHANGES[@]/$pattern/} ) +for f in $BLACKLIST; do + FILES=( ${FILES[@]/$f/} ) # If we've exhausted the list of changes before we've finished going # through patterns, that's okay, just quit the loop - if [[ ${#CHANGES[@]} -eq 0 ]]; then + if [[ ${#FILES[@]} -eq 0 ]]; then break fi done # If there's changes left, then we have stuff to build, leave the commit alone -if [[ ${#CHANGES[@]} -gt 0 ]]; then +if [[ ${#FILES[@]} -gt 0 ]]; then exit fi # Prefix the commit message with "[skip ci]" -sed -i '1s/$/ [skip ci]/' "$1" +sed -i '' '1s/$/ [skip ci]/' "$1" # We're good exit 0