From e6e50766981c2063124c9e1b6973f4ddb108e734 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Wed, 19 Mar 2014 21:05:16 -0500 Subject: [PATCH] Enforce alphabetical ordering of element-deps We've started to require this in reviews, so we should really have automation in place to catch it right away. Change-Id: I43fd90647acba400cea11c665fb587856514b0ee --- bin/dib-lint | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bin/dib-lint b/bin/dib-lint index a4b1cfe89..01b28c398 100755 --- a/bin/dib-lint +++ b/bin/dib-lint @@ -19,6 +19,8 @@ # common mistakes and exits with a non-zero status if it finds any. rc=0 +TMPDIR=$(mktemp -d) +trap "rm -rf $TMPDIR" EXIT for i in $(find elements -type f); do # Check that files starting with a shebang are +x firstline=$(head -n 1 "$i") @@ -26,5 +28,18 @@ for i in $(find elements -type f); do echo "ERROR: $i is not executable" rc=1 fi + + # Check alphabetical ordering of element-deps + if [ $(basename $i) = "element-deps" ]; then + UNSORTED=${TMPDIR}/element-deps.unsorted + SORTED=${TMPDIR}/element-deps.sorted + grep -v '^#' $i > ${UNSORTED} + sort ${UNSORTED} > ${SORTED} + diff -c ${UNSORTED} ${SORTED} + if [ $? -ne 0 ]; then + echo "ERROR: $i is not sorted alphabetically" + rc=1 + fi + fi done exit $rc \ No newline at end of file