git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/4] Documentation/lint-manpages: bubble up errors

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 6, 2024, 08:01 UTC
Message-ID
<9f21c305b9e0e63ddf1f1b78535f09ae957812d4.1717660597.git.ps@pks.im>
In-Reply-To
<cover.1717660597.git.ps@pks.im>

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>
---
 Documentation/lint-manpages.sh | 41 +++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/Documentation/lint-manpages.sh b/Documentation/lint-manpages.sh
index 0abb4e0b4c..92cfc0a15a 100755
--- a/Documentation/lint-manpages.sh
+++ b/Documentation/lint-manpages.sh
@@ -12,7 +12,9 @@ EOF
 	sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
 }
 
-check_missing_docs () {
+check_missing_docs () (
+	ret=0
+
 	for v in $ALL_COMMANDS
 	do
 		case "$v" in
@@ -32,6 +34,7 @@ check_missing_docs () {
 		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 |
@@ -41,11 +44,15 @@ check_missing_docs () {
 			git)
 				;;
 			*)
-				echo "no link: $v";;
+				echo "no link: $v"
+				ret=1
+				;;
 			esac
 		fi
 	done
-}
+
+	exit $ret
+)
 
 check_extraneous_docs () {
 	(
@@ -61,15 +68,19 @@ check_extraneous_docs () {
 		    -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";;
+				echo "removed but $how: $cmd"
+				ret=1;;
 			esac
 		done
+
+		exit $ret
 	)
 }
 
@@ -77,7 +88,21 @@ BUILT_INS="$(extract_variable BUILT_INS)"
 ALL_COMMANDS="$(extract_variable ALL_COMMANDS)"
 EXCLUDED_PROGRAMS="$(extract_variable EXCLUDED_PROGRAMS)"
 
-{
-	check_missing_docs
-	check_extraneous_docs
-} | sort
+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
-- 
2.45.2.409.g7b0defb391.dirty
Previous: Junio C HamanoNext: Patrick Steinhardt
Message 15 of 18 in “Documentation: improve linting of manpage existence”
  1. 0/4 Documentation: improve linting of manpage existencePatrick Steinhardt, Jun 5, 2024
  2. 1/4 Makefile: extract script to lint missing/extraneous manpagesPatrick Steinhardt, Jun 5, 2024
  3. Junio C HamanoJun 5, 2024
  4. Patrick SteinhardtJun 5, 2024
  5. James LiuJun 6, 2024
  6. Junio C HamanoJun 6, 2024
  7. 2/4 Documentation/lint-manpages: bubble up errorsPatrick Steinhardt, Jun 5, 2024
  8. Junio C HamanoJun 5, 2024
  9. 3/4 gitlab-ci: add job to run `make check-docs`Patrick Steinhardt, Jun 5, 2024
  10. 4/4 ci/test-documentation: work around SyntaxWarning in Python 3.12Patrick Steinhardt, Jun 5, 2024
  11. Junio C HamanoJun 5, 2024
  12. 0/4 Documentation: improve linting for manpage existencePatrick Steinhardt, Jun 6, 2024
  13. 1/4 Makefile: extract script to lint missing/extraneous manpagesPatrick Steinhardt, Jun 6, 2024
  14. Junio C HamanoJun 7, 2024
  15. 2/4 Documentation/lint-manpages: bubble up errorsPatrick Steinhardt, Jun 6, 2024
  16. 3/4 gitlab-ci: add job to run `make check-docs`Patrick Steinhardt, Jun 6, 2024
  17. 4/4 ci/test-documentation: work around SyntaxWarning in Python 3.12Patrick Steinhardt, Jun 6, 2024
  18. James LiuJun 7, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.