summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-04-11 00:24:21 +0000
committerGerrit Code Review <review@openstack.org>2014-04-11 00:24:21 +0000
commitb7ae16025bcbbd653a9f15b308128c321bf7bd1a (patch)
treea38f801eb951ec4821b62d3b6ba8067b448fa453 /tools
parent1763e920a1da94f7eece08d581c6a81d5f6e4bda (diff)
parent035abae6ef6c87f7439392de955e3c55882bfa73 (diff)
downloadheat-b7ae16025bcbbd653a9f15b308128c321bf7bd1a.tar.gz
Merge "Sort requirement files in alphabetical order"
Diffstat (limited to 'tools')
-rwxr-xr-xtools/requirements_style_check.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/requirements_style_check.sh b/tools/requirements_style_check.sh
new file mode 100755
index 000000000..ccbff3bdd
--- /dev/null
+++ b/tools/requirements_style_check.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Enforce the requirement that dependencies are listed in the input
+# files in alphabetical order.
+
+# FIXME(dhellmann): This doesn't deal with URL requirements very
+# well. We should probably sort those on the egg-name, rather than the
+# full line.
+
+function check_file() {
+ typeset f=$1
+
+ # We don't care about comment lines.
+ grep -v '^#' $f > ${f}.unsorted
+ sort -i -f ${f}.unsorted > ${f}.sorted
+ diff -c ${f}.unsorted ${f}.sorted
+ rc=$?
+ rm -f ${f}.sorted ${f}.unsorted
+ return $rc
+}
+
+exit_code=0
+for filename in $@
+do
+ check_file $filename
+ if [ $? -ne 0 ]
+ then
+ echo "Please list requirements in $filename in alphabetical order" 1>&2
+ exit_code=1
+ fi
+done
+exit $exit_code