portbump: improve checksum matching and handling#378
portbump: improve checksum matching and handling#378herbygillot merged 1 commit intomacports:masterfrom
Conversation
b4f56e3 to
b582f70
Compare
|
On a somewhat related note, the traditional approach (pasting some output from |
Here's a PR that will do the right thing in regards to formatting for |
d78a764 to
e349dd8
Compare
…andling
Drop sed(1) entirely from portbump. Instead, read the Portfile into a
line list and use three new procs for targeted modifications:
- replace_checksums: match hash values as whole words using \y
word-boundary anchors, so a size value like 123 cannot accidentally
clobber a larger value such as 12345; targets only the correct lines
even with multiple subports, conditional branches, or variant-scoped
checksums.
- find_revision_line: two-phase strategy — first check for an inline
revision on the subport declaration line (e.g. llvm pattern), then
fall back to the nearest standalone revision line, excluding lines
inside subport { } blocks when bumping the parent port.
- reset_revision: simple regsub to set revision to 0, preserving
indentation and surrounding text.
Fixes a bug where both_checksums was reset on each distfile iteration,
causing only the last distfile's checksums to be updated in Portfiles
with multiple distfiles (e.g. git with git-manpages and git-htmldocs).
Fixes a bug where already-correct checksums were shown in the
"We will bump these:" output.
Also fixes a bug where patch mode applied file attributes to the
Portfile instead of the patch file.
Removes dead code left over from the sed-based implementation.
Adds comprehensive test suite covering real-world Portfile patterns
(git, go, llvm-16, gradle), including tests for whole-word size
matching, subport blocks with nested braces, multiple distfiles,
partial mismatch, and the no-revision-line code path.
Closes: https://trac.macports.org/ticket/65601
Closes: https://trac.macports.org/ticket/73593
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e349dd8 to
fb08b3b
Compare
|
You're not always going to get a review as quickly as you would like. MacPorts is not anybody's day job and there has been a lot going on recently. I'm not going to do a major release without going through the pending PRs. |
Yes, I certainly understand that. |
Drop sed(1) entirely from portbump. Instead, read the Portfile into a
line list and use three new procs for targeted modifications:
replace_checksums: match on unique hash values rather than regex
patterns, so only the correct lines are modified even with multiple
subports, conditional branches, or variant-scoped checksums.
find_revision_line: two-phase strategy — first check for an inline
revision on the subport declaration line (e.g. llvm pattern), then
fall back to the nearest standalone revision line, excluding lines
inside subport { } blocks when bumping the parent port.
reset_revision: simple regsub to set revision to 0, preserving
indentation and surrounding text.
Fixes a bug where both_checksums was reset on each distfile iteration,
causing only the last distfile's checksums to be updated in Portfiles
with multiple distfiles (e.g. git with git-manpages and git-htmldocs).
Also fixes a bug where patch mode applied file attributes to the
Portfile instead of the patch file.
Removes dead code left over from the sed-based implementation.
Adds comprehensive test suite covering real-world Portfile patterns
(git, go, llvm-16, gradle), including tests for size field replacement,
subport blocks with nested braces, multiple distfiles, and the
no-revision-line code path.
Closes: https://trac.macports.org/ticket/65601
Closes: https://trac.macports.org/ticket/73593