governance/tools/check_projects_yaml_alphabetized.sh
Graham Hayes aaef9cc8f0
Allow yaml checks to work with mktemp in a different path
Change-Id: I960c680f1e2bae93fea047a4ef805e6e748dc5b9
Signed-off-by: Graham Hayes <gr@ham.ie>
2019-06-28 12:40:52 +01:00

28 lines
674 B
Bash
Executable File

#!/bin/bash -xe
# Checks that reference/projects.yaml alphabetized and prints list of
# projects that should be sorted.
if [ -x "$(command -v mktemp)" ]; then
export TMPDIR=`mktemp -d`
else
export TMPDIR=`/bin/mktemp -d`
fi
trap "rm -rf $TMPDIR" EXIT
pushd $TMPDIR
PROJECTS_LIST=$OLDPWD/reference/projects.yaml
grep '^[a-zA-Z0-9]' $PROJECTS_LIST > projects_list
LC_ALL=C sort --ignore-case projects_list -o projects_list.sorted
if ! diff projects_list projects_list.sorted > projects_list.diff; then
echo "The following projects should be alphabetized: "
cat projects_list.diff | grep -e '> '
exit 1
else
echo "Projects alphabetized."
fi
popd