aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss.ws@gmail.com>2016-11-01 21:29:11 -0400
committerAnders Broman <a.broman58@gmail.com>2016-11-02 04:42:47 +0000
commit8a376d4cd35e1e00b4c1bbd30ad85c6eda0561f3 (patch)
treeadb60974e103042bd34c670d1b6d5f56e92f99f4 /tools
parente1454337df5cee341f7973fbd8c2d9cc8cba9586 (diff)
Validate the Diameter XML files in the pre-commit script.
Validation requires xmllint but will pass (with a complaint) if the committer does not have xmllint installed. Change-Id: I336a1c8ad8e1f98805a284d8c4736810b1a9c54e Reviewed-on: https://code.wireshark.org/review/18609 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/pre-commit6
-rwxr-xr-xtools/validate-diameter-xml.sh18
2 files changed, 17 insertions, 7 deletions
diff --git a/tools/pre-commit b/tools/pre-commit
index 75269264b0..3d2b009e49 100755
--- a/tools/pre-commit
+++ b/tools/pre-commit
@@ -53,6 +53,7 @@ fi
exit_status=0
COMMIT_FILES=`git diff-index --cached --name-status ${COMMIT_ID} | grep -v "^D" | cut -f2 | grep "\.[ch]$"`
+DIAMETER_FILES=`git diff-index --cached --name-status ${COMMIT_ID} | grep -v "^D" | cut -f2 | grep diameter/`
# Path to filter script in the tools directory
filter_script=${PWD}/tools/pre-commit-ignore.py
@@ -91,6 +92,11 @@ for FILE in $CHECK_FILES; do
done
+if [ "x$DIAMETER_FILES" != x ]
+then
+ ./tools/validate-diameter-xml.sh > /dev/null || exit_status=1
+fi
+
# If there are whitespace errors, print the offending file names and fail. (from git pre-commit.sample)
git diff-index --check --cached ${COMMIT_ID} || exit_status=1
diff --git a/tools/validate-diameter-xml.sh b/tools/validate-diameter-xml.sh
index 09aa4af6aa..98c496ff28 100755
--- a/tools/validate-diameter-xml.sh
+++ b/tools/validate-diameter-xml.sh
@@ -24,24 +24,28 @@
if ! type -p sed > /dev/null
then
- echo "Sorry, 'sed' is needed to run this program."
- exit 1
+ echo "'sed' is needed to run $0." 1>&2
+ # Exit cleanly because we don't want pre-commit to fail just because
+ # someone doesn't have the tools...
+ exit 0
fi
if ! type -p xmllint > /dev/null
then
- echo "Sorry, 'xmllint' is needed to run this program."
- exit 1
+ echo "'xmllint' is needed to run $0." 1>&2
+ # Exit cleanly because we don't want pre-commit to fail just because
+ # someone doesn't have the tools...
+ exit 0
fi
# Ideally this would work regardless of our cwd
if [ ! -r diameter/dictionary.xml ]
then
- echo "Couldn't find diameter/dictionary.xml"
+ echo "Couldn't find diameter/dictionary.xml" 1>&2
exit 1
fi
if [ ! -r diameter/dictionary.dtd ]
then
- echo "Couldn't find diameter/dictionary.dtd"
+ echo "Couldn't find diameter/dictionary.dtd" 1>&2
exit 1
fi
@@ -59,7 +63,7 @@ do
done
xmllint --noout --noent --postvalid /tmp/diameter/dictionary.xml &&
- echo "Diameter dictionary is (mostly) valid XML!"
+ echo "Diameter dictionary is (mostly) valid XML."
rm -rf /tmp/diameter