blob: 4c1279958e98429901f69e1ceaf3bce278b5934e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Check that every "F:" file reference in MAINTAINERS exists.
#
# Each F: entry is treated as a shell glob (relative to the repo root),
# matching the way MAINTAINERS wildcards work. If a pattern matches no
# existing file or directory, it is reported and the script exits non-zero.
set -u
MAINTAINERS="${1:-MAINTAINERS}"
if [ ! -f "$MAINTAINERS" ]; then
echo "error: cannot find $MAINTAINERS" >&2
exit 2
fi
rc=0
while IFS= read -r pattern; do
# Strip the "F:" prefix and surrounding whitespace.
pattern=$(printf '%s\n' "$pattern" | sed -e 's/^F:[[:space:]]*//' -e 's/[[:space:]]*$//')
[ -n "$pattern" ] || continue
# Expand the pattern as a glob; if nothing matches the glob stays literal.
matched=0
for path in $pattern; do
if [ -e "$path" ]; then
matched=1
break
fi
done
if [ "$matched" -eq 0 ]; then
echo "error: MAINTAINERS references non-existing file: $pattern" >&2
rc=1
fi
done <<EOF
$(grep '^F:' "$MAINTAINERS")
EOF
if [ "$rc" -eq 0 ]; then
echo "All MAINTAINERS F: entries exist."
fi
exit $rc
|