project-config/tools/check_valid_gerrit_config.sh
Andreas Jaeger 5e7ad13490 Improve gerrit checks messages
For tools/check_valid_gerrit_projects.py:
* Improve one error message to mention the project as well.

For tools/check_valid_gerrit_config.sh:
* Remove output for each ACL we check, we output the entry if it's
  wrong. But with 800+ ACL lines, we should not output 800+ lines of
  progress and thus make it hard to find the one failing line.

Change-Id: I4434c0f0bf65a1eb69889a2362c1abae7119fdd7
2016-09-13 13:57:48 +02:00

41 lines
1.0 KiB
Bash
Executable File

#!/bin/bash -e
# It checks that *.config files respect certain gerrit ACL rules
export TMPDIR=$(/bin/mktemp -d)
trap "rm -rf $TMPDIR" EXIT
pushd $TMPDIR
CONFIGS_LIST_BASE=$OLDPWD/$1
function check_team_acl {
local configs_dir="$1"
local configs_list=$(find $configs_dir -name "*.config")
local failure=0
for config in $configs_list; do
$OLDPWD/tools/normalize_acl.py $config all > $TMPDIR/normalized
if ! diff -u $config $TMPDIR/normalized >>config_failures;
then
echo "Project $config is not normalized!" >>config_failures
fi
done
}
# Add more namespaces here, if necessary
for namespace in openstack openstack-dev openstack-infra stackforge; do
check_team_acl "${CONFIGS_LIST_BASE}${namespace}"
done
num_errors=$(cat config_failures | grep "is not normalized" | wc -l)
if [ $num_errors -ne 0 ]; then
echo -e; cat config_failures
echo -e "There are $num_errors projects not normalized."
exit 1
fi
echo "Gerrit ACL configs are valid!"
popd