From 4cfd1d7d6cfedf612e18e7e9b34215e6577e547c Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 16 Mar 2017 18:35:02 +0100 Subject: [PATCH] Added githook to skip CI build on non-src changes --- .githooks/commit-msg/skip.sh | 54 +++++++++++++++++++ .../post-merge/{npm-update.sh => install.sh} | 0 .travisignore | 5 ++ 3 files changed, 59 insertions(+) create mode 100644 .githooks/commit-msg/skip.sh rename .githooks/post-merge/{npm-update.sh => install.sh} (100%) create mode 100644 .travisignore diff --git a/.githooks/commit-msg/skip.sh b/.githooks/commit-msg/skip.sh new file mode 100644 index 000000000..76d952d53 --- /dev/null +++ b/.githooks/commit-msg/skip.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Copyright (c) 2016-2017 Martin Donath + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +# Exit, if there's no .travisignore file +if [[ ! -a .travisignore ]]; then + exit +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 + +# Remove the pattern from the list of changes +for $pattern in "${BLACKLIST[@]}"; do + CHANGES=( ${CHANGES[@]/$pattern/} ) + + # 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 + break + fi +done + +# If there's changes left, then we have stuff to build, leave the commit alone +if [[ ${#CHANGES[@]} -gt 0 ]]; then + exit +fi + +# Prefix the commit message with "[skip ci]" +sed -i '1s/$/ [skip ci]/' "$1" + +# We're good +exit 0 diff --git a/.githooks/post-merge/npm-update.sh b/.githooks/post-merge/install.sh similarity index 100% rename from .githooks/post-merge/npm-update.sh rename to .githooks/post-merge/install.sh diff --git a/.travisignore b/.travisignore new file mode 100644 index 000000000..747ccf96d --- /dev/null +++ b/.travisignore @@ -0,0 +1,5 @@ +.github/* +docs/* +material/* +CHANGELOG +*.md