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
This commit is contained in:
Ben Nemec 2014-03-19 21:05:16 -05:00
parent 63230414d2
commit e6e5076698

View File

@ -19,6 +19,8 @@
# common mistakes and exits with a non-zero status if it finds any. # common mistakes and exits with a non-zero status if it finds any.
rc=0 rc=0
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT
for i in $(find elements -type f); do for i in $(find elements -type f); do
# Check that files starting with a shebang are +x # Check that files starting with a shebang are +x
firstline=$(head -n 1 "$i") firstline=$(head -n 1 "$i")
@ -26,5 +28,18 @@ for i in $(find elements -type f); do
echo "ERROR: $i is not executable" echo "ERROR: $i is not executable"
rc=1 rc=1
fi 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 done
exit $rc exit $rc