From 0a609d419527b3f0cd15b2a66f9be5df3718c3a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Thu, 18 Aug 2016 08:47:49 +0100 Subject: pre-commit: Ignore missing pre-commit-ignore.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Print error message to stderr and return non-zero exit status from child process. Change-Id: Icd433d79c5a7bf8b6ddd8e94e26695b353e34d1f Reviewed-on: https://code.wireshark.org/review/17116 Reviewed-by: Peter Wu Petri-Dish: João Valverde Reviewed-by: João Valverde --- tools/pre-commit | 12 ++++-------- tools/pre-commit-ignore.py | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'tools') diff --git a/tools/pre-commit b/tools/pre-commit index 35895a4cf1..b5a7d8eab4 100755 --- a/tools/pre-commit +++ b/tools/pre-commit @@ -55,14 +55,10 @@ COMMIT_FILES=`git diff-index --cached --name-status ${COMMIT_ID} | grep -v "^D" filter_script=${PWD}/tools/pre-commit-ignore.py filter_conf=${PWD}/tools/pre-commit-ignore.conf -if [ ! -e "$filter_script" ]; then - echo "File '$filter_script' does not exist. Aborting." - exit 1 -fi - -CHECK_FILES=`echo "$COMMIT_FILES" | "$PYBIN" "$filter_script" "$filter_conf"` -if [ $? -ne 0 ]; then - exit 1 +if [ -f "$filter_script" ] && [ -f "$filter_conf" ]; then + CHECK_FILES=`echo "$COMMIT_FILES" | "$PYBIN" "$filter_script" "$filter_conf"` || exit +else + CHECK_FILES="$COMMIT_FILES" fi # On windows python will output \r\n line endings - we don't want that. diff --git a/tools/pre-commit-ignore.py b/tools/pre-commit-ignore.py index d043368a95..e55d42b949 100755 --- a/tools/pre-commit-ignore.py +++ b/tools/pre-commit-ignore.py @@ -40,8 +40,7 @@ def load_checkignore(path): with open(path) as f: patterns = f.read() except OSError as err: - print(str(err)) - return [] + sys.exit(str(err)) ign = [l.strip() for l in patterns.splitlines()] ign = [l for l in ign if l and not l.startswith("#")] return ign -- cgit v1.2.1