e5c26d38f8
* Check for space indentation instead of tabs * Check that an entry actually exists * Check that a directory ends in a slash, otherwise GitLab seems to ignore it
43 lines
1.1 KiB
Bash
Executable file
43 lines
1.1 KiB
Bash
Executable file
#!/bin/sh -e
|
|
# Description: verify CODEOWNERS file is sane
|
|
# https://postmarketos.org/pmb-ci
|
|
|
|
# TODO Future improvements:
|
|
# * Check that all devices in main/community have someone in CODEOWNERS
|
|
# * Check that GitLab user actually exists (e.g. deleted account, account with
|
|
# changed user name)
|
|
|
|
if grep -q " " CODEOWNERS; then
|
|
echo
|
|
echo "ERROR: Found space indentation in CODEOWNERS."
|
|
echo "ERROR: Please indent with tab characters."
|
|
grep " " CODEOWNERS
|
|
echo
|
|
exit 1
|
|
fi
|
|
|
|
fail=0
|
|
tmppipe=$(mktemp -u)
|
|
mkfifo "$tmppipe"
|
|
grep -v "^#" CODEOWNERS | cut -d' ' -f1 > "$tmppipe" &
|
|
while IFS= read -r line; do
|
|
[ -z "$line" ] && continue
|
|
|
|
# Check if entry generally exists
|
|
# shellcheck disable=SC2086
|
|
ls $line >/dev/null 2>&1 || { fail=1; echo "Non-existing: $line"; }
|
|
|
|
# Check that directories end with a slash
|
|
# shellcheck disable=SC2086
|
|
if test -d "$(ls -d $line)"; then
|
|
echo "$line" | grep -q '/$' || { fail=1; echo "Missing trailing slash: $line"; }
|
|
fi
|
|
done < "$tmppipe"
|
|
rm "$tmppipe"
|
|
|
|
if [ "$fail" = 1 ]; then
|
|
echo
|
|
echo "ERROR: Invalid CODEOWNERS entries, see above."
|
|
echo
|
|
exit 1
|
|
fi
|