summaryrefslogtreecommitdiffstats
path: root/bin/tidy-bowl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/tidy-bowl')
-rwxr-xr-xbin/tidy-bowl63
1 files changed, 63 insertions, 0 deletions
diff --git a/bin/tidy-bowl b/bin/tidy-bowl
new file mode 100755
index 0000000..aac11a2
--- /dev/null
+++ b/bin/tidy-bowl
@@ -0,0 +1,63 @@
+#!/bin/sh
+########################################################################
+#
+# This script is invoked by "commitinfo" just after the incoming file has
+# been uploaded to the server. It gets passed these arguments:
+#
+# tidy-bowl file ...
+#
+# If we approve of the commit for EVERY file in the list, then we return
+# a zero (0). Any non-zero return aborts the commit, so we must be very
+# careful here.
+#
+# AFAIK, the $PWD is the temporary file where the incoming "file" is located,
+# but that needs to be verified.
+#
+# For every "file" that ends with ".xml", we will attempt to normalize the
+# formatting by using tidy(1) to prettyprint it. We must overwrite "file" so
+# that the rest of CVS knows where to find the file.
+#
+# There doesn't seem to be any way to return error messages, so we'll just bang
+# them out to "/var/log/messages".
+#
+########################################################################
+# exit 0 # Early exit while frobbing around
+########################################################################
+# All ancillary files should be in the same directory as this script
+ME=`/bin/basename $0`
+PREFIX=`/usr/bin/dirname $0`
+########################################################################
+USAGE="Usage: ${ME} [-T tool] [-t tool-args] file..."
+NORMTOOL=${PREFIX}/xmlformat
+NORMARGS="-i -v -f ${PREFIX}/xmlformat-fdp.conf"
+while getopts T:t: c
+do
+ case "${c}" in
+ T) NORMTOOL="${OPTARG}";;
+ t) NORMARGS="${OPTARG}";;
+ *) /bin/echo "${USAGE}" >&2; exit 1;;
+ esac
+done
+shift `/usr/bin/expr "${OPTIND}" - 1`
+########################################################################
+for fn in $@
+do
+ case "${fn}" in
+ *.[Xx][Mm][Ll] )
+ # Make sure we can find the input file
+ if [ ! -f "${fn}" ]; then
+ /bin/echo $0 "Cannot find '${fn}'"
+ exit 1
+ fi
+ # Try to clean it up
+ ${NORMTOOL} ${NORMARGS} "${fn}"
+ if [ $? -ne 0 ]; then
+ /bin/echo $0 "File '${fn}' unclean."
+ exit 1
+ fi
+ ;;
+ * )
+ ;;
+ esac
+done
+exit 0