summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-08-18 08:47:49 +0100
committerJoão Valverde <j@v6e.pt>2016-08-18 11:00:27 +0000
commit0a609d419527b3f0cd15b2a66f9be5df3718c3a8 (patch)
treeeebe6cf7e73771b95c8cee79562b5aa49f685ca6 /tools
parentb366d6e4dd5f14cfea820d132ee16b45b18bd869 (diff)
downloadwireshark-0a609d419527b3f0cd15b2a66f9be5df3718c3a8.tar.gz
pre-commit: Ignore missing pre-commit-ignore.py
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 <peter@lekensteyn.nl> Petri-Dish: João Valverde <j@v6e.pt> Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/pre-commit12
-rwxr-xr-xtools/pre-commit-ignore.py3
2 files changed, 5 insertions, 10 deletions
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