561ac5dc82
When the ACL file normalization checker failed it only mentioned the filename, with the actual error output from diff potentially many many lines up in the scrollback. This change saves the diff output so it can be reported at the end of the run where the failure happens. Change-Id: I862f755c6ed96208c0fe8255175afb48847f8cad
42 lines
1.0 KiB
Bash
Executable File
42 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
|
|
echo "Checking $config file..."
|
|
|
|
$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
|