Repository navigation
tools/kernel-pr-check: work the --help range out from the file - #529
Merged
derekross merged 1 commit intoNov 9, 2026
Merged
Conversation
--help printed a hard-coded line range of the header comment, so every change to the header had to move the range by hand: derekross#287 and derekross#288 each added a header line and both set it to '3,37p', and with derekross#310 on main the merged ranges became '3,46p' and '3,47p'. Whichever change missed the update cut the header's last line. On derekross#287 the maintainer suggested working the range out from the file instead. --help now prints from line 3 to the first line that isn't a comment, with the awk line tools/nv-backup and tools/phone-provision already use (without their "# " stripping, so the output keeps its current form). On today's header its output is byte for byte what '3,49p' printed. tests/kernel-pr-check gains a check that runs --help on a copy of the tool with one more header line, and compares it with the header up to the line before `set -uo pipefail`. It failed with the old range (the last header line was missing) and passes with this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 of 9 tasks
Owner
|
Thank you, Victor. Small and right: I checked that the new line prints exactly what |
6 of 9 tasks
derekross
added a commit
that referenced
this pull request
Nov 9, 2026
Fourteen tools printed --help as a hard-coded line range of their header comment (sed -n '3,NNp'), the pattern that cut kernel-pr-check's header after #287, #288 and #310 each edited it. On #287 the maintainer suggested working the range out from the file; #529 did that for kernel-pr-check alone. This moves all of them onto one helper, tools/lib/usage.sh: usage_from_header prints the comment lines from line 3 up to the first line that isn't a comment (#529's awk line), with "# " taken off or, with --raw, kept. Tools load it only for --help, so the copies the tests make of a tool, with only the lib files it needs, still run. kernel-pr-check moves onto it too. Ten tools print byte for byte what they printed before (cmp of stdout, stderr and exit status, and of phone-demo's and phone-mirror's error usage). Five ranges were already wrong, and print the header now: fetch-toolchain and build-flame-probe printed two lines of code after it; install-phone cut --reinstall, --unsigned and its last paragraph, build-rootfs cut --channel, and release cut its check-bundle stage. build-packages, phone-demo and release print only the start of a longer header, so the helper takes a paragraph count (a bare "#" line ends one) and their output stays what the range meant. install-phone keeps the awk line inline, as nv-backup and phone-provision already do: make-bundle ships these three alone, without tools/lib (review lesson L-497). tests/tools-help fails if any tool still hard-codes the range, and runs --help on every tool that prints its header (the helper's users and the three inline ones): it must print the header, or whole paragraphs from its start, and no code, and a copy whose header has grown by a line must print that line too. It replaces #529's single-tool check in tests/kernel-pr-check. On the base it fails on the range check, and the per-tool check fails for 13 of the 15 tools. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Derek Ross <derekross@gmail.com>
robertzas
pushed a commit
to robertzas/omarchy-mobile
that referenced
this pull request
Nov 14, 2026
…ross#529) --help printed a hard-coded line range of the header comment, so every change to the header had to move the range by hand: derekross#287 and derekross#288 each added a header line and both set it to '3,37p', and with derekross#310 on main the merged ranges became '3,46p' and '3,47p'. Whichever change missed the update cut the header's last line. On derekross#287 the maintainer suggested working the range out from the file instead. --help now prints from line 3 to the first line that isn't a comment, with the awk line tools/nv-backup and tools/phone-provision already use (without their "# " stripping, so the output keeps its current form). On today's header its output is byte for byte what '3,49p' printed. tests/kernel-pr-check gains a check that runs --help on a copy of the tool with one more header line, and compares it with the header up to the line before `set -uo pipefail`. It failed with the old range (the last header line was missing) and passes with this change. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
robertzas
pushed a commit
to robertzas/omarchy-mobile
that referenced
this pull request
Nov 14, 2026
…ekross#559) Fourteen tools printed --help as a hard-coded line range of their header comment (sed -n '3,NNp'), the pattern that cut kernel-pr-check's header after derekross#287, derekross#288 and derekross#310 each edited it. On derekross#287 the maintainer suggested working the range out from the file; derekross#529 did that for kernel-pr-check alone. This moves all of them onto one helper, tools/lib/usage.sh: usage_from_header prints the comment lines from line 3 up to the first line that isn't a comment (derekross#529's awk line), with "# " taken off or, with --raw, kept. Tools load it only for --help, so the copies the tests make of a tool, with only the lib files it needs, still run. kernel-pr-check moves onto it too. Ten tools print byte for byte what they printed before (cmp of stdout, stderr and exit status, and of phone-demo's and phone-mirror's error usage). Five ranges were already wrong, and print the header now: fetch-toolchain and build-flame-probe printed two lines of code after it; install-phone cut --reinstall, --unsigned and its last paragraph, build-rootfs cut --channel, and release cut its check-bundle stage. build-packages, phone-demo and release print only the start of a longer header, so the helper takes a paragraph count (a bare "#" line ends one) and their output stays what the range meant. install-phone keeps the awk line inline, as nv-backup and phone-provision already do: make-bundle ships these three alone, without tools/lib (review lesson L-497). tests/tools-help fails if any tool still hard-codes the range, and runs --help on every tool that prints its header (the helper's users and the three inline ones): it must print the header, or whole paragraphs from its start, and no code, and a copy whose header has grown by a line must print that line too. It replaces derekross#529's single-tool check in tests/kernel-pr-check. On the base it fails on the range check, and the per-tool check fails for 13 of the 15 tools. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Derek Ross <derekross@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
tools/kernel-pr-check --helpprinted a hard-coded range of its header comment (sed -n '3,NNp'), so every header edit had to move the range by hand. #287 and #288 each added a header line, and with #310 the range became3,46p/3,47pand then3,49p. Each time, whichever change missed the update cut the header's last line. On #287 the maintainer suggested working the range out from the file.--helpnow prints from line 3 to the first line that isn't a comment. It's the awk linetools/nv-backupandtools/phone-provisionalready use, without their#stripping, so the output keeps its current form. On today's header the output is byte for byte what3,49pprinted (cmpbefore/after: identical).tests/kernel-pr-checkgains a check: on a copy of the tool with one more header line,--helpmust equal the header up to the line beforeset -uo pipefail. It fails with the old range (the last header line is missing) and passes with this change.Other tools with the same hard-coded pattern, not changed here:
fetch-toolchain,build-flame-probe,release-upload,install-phone,build-rootfs,build-packages,fetch-published,make-bundle,release,phone-smoke,publish-kernel,repo-publish, andusage()inphone-demoandphone-mirror. If you'd like, a shared helper intools/libcould replace them in a separate PR.Device and build
uname -r): n/aChecks (no phone needed)
tools/pr-check origin/mainpassestests/allpassestests/packagespasses (or the packages I touched: none)versionbumped, and the new version is in the commit subject (no package changed)Co-Authored-By:orAssisted-by:trailer, never aSigned-off-by:On the phone
userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)tools/phone-smokereportNot applicable: a laptop-tool change (CONTRIBUTING.md §6.5).
Generated with Claude Opus 5.5 in T3 Code Nightly