1
0
mirror of https://github.com/git/git synced 2024-06-30 22:54:27 +00:00
git/Documentation/lint-manpages.sh
Patrick Steinhardt 6423920974 Documentation/lint-manpages: bubble up errors
The "lint-manpages.sh" script does not return an error in case any of
its checks fail. While this is faithful to the implementation that we
had as part of the "check-docs" target before the preceding commit, it
makes it hard to spot any violations of the rules via the corresponding
CI job, which will of course exit successfully, too.

Adapt the script to bubble up errors.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-06-06 08:20:51 -07:00

109 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
extract_variable () {
(
cat ../Makefile
cat <<EOF
print_variable:
@\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
EOF
) |
make -C .. -f - print_variable 2>/dev/null |
sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
}
check_missing_docs () (
ret=0
for v in $ALL_COMMANDS
do
case "$v" in
git-merge-octopus) continue;;
git-merge-ours) continue;;
git-merge-recursive) continue;;
git-merge-resolve) continue;;
git-merge-subtree) continue;;
git-fsck-objects) continue;;
git-init-db) continue;;
git-remote-*) continue;;
git-stage) continue;;
git-legacy-*) continue;;
git-?*--?* ) continue ;;
esac
if ! test -f "$v.txt"
then
echo "no doc: $v"
ret=1
fi
if ! sed -e '1,/^### command list/d' -e '/^#/d' ../command-list.txt |
grep -q "^$v[ ]"
then
case "$v" in
git)
;;
*)
echo "no link: $v"
ret=1
;;
esac
fi
done
exit $ret
)
check_extraneous_docs () {
(
sed -e '1,/^### command list/d' \
-e '/^#/d' \
-e '/guide$/d' \
-e '/interfaces$/d' \
-e 's/[ ].*//' \
-e 's/^/listed /' ../command-list.txt
make print-man1 |
grep '\.txt$' |
sed -e 's|^|documented |' \
-e 's/\.txt//'
) | (
all_commands="$(printf "%s " "$ALL_COMMANDS" "$BUILT_INS" "$EXCLUDED_PROGRAMS" | tr '\n' ' ')"
ret=0
while read how cmd
do
case " $all_commands " in
*" $cmd "*) ;;
*)
echo "removed but $how: $cmd"
ret=1;;
esac
done
exit $ret
)
}
BUILT_INS="$(extract_variable BUILT_INS)"
ALL_COMMANDS="$(extract_variable ALL_COMMANDS)"
EXCLUDED_PROGRAMS="$(extract_variable EXCLUDED_PROGRAMS)"
findings=$(
if ! check_missing_docs
then
ret=1
fi
if ! check_extraneous_docs
then
ret=1
fi
exit $ret
)
ret=$?
printf "%s" "$findings" | sort
exit $ret