Fix regex in epoch_sed#25
Conversation
There was a problem hiding this comment.
Hey, this looks great, thanks for the fix!
I (well, Claude) noticed another issue that I was hoping you could fix too.
# testing with an epoch value greater than 9 to verify all digits are captured correctly:
echo " epoch: 123" | sed -r 's/^[[:space:]]+epoch:[[:space:]]+([0-9])+.*$/\1/' # Returns: 3 ❌
echo " epoch: 123" | sed -r 's/^[[:space:]]+epoch:[[:space:]]+([0-9]+).*$/\1/' # Returns: 123 ✅
Otherwise though, with both fixes, I think this'll be in really good shape.
echo " epoch: 123 # cve comment" | sed -r 's/^[[:space:]]+epoch:[[:space:]]+([0-9]+).*$/\1/'
123
|
Oh, yeah, that's actually correct (I don't trust the LLMs at all), I didn't have any with an epoch > 9 in my set of changes! "Reasons why I like unit tests" 😁 |
There was a problem hiding this comment.
Yeah I definitely had to made sure it was being honest haha, but it seemed to check out so I figured I'd mention it too. I haven't run into it failing on >9 yet either but I know some packages are like that. I'd love to have a test suite for the pre-commit scripts at some point, but for now, I think we're in pretty good shape.
|
For yucks I ran a grep for two-digit epochs, there are 5 in |
Get latest chaingguard pre-commit hook to pick up the fix to ignore trailing comments after epoch numbers when checking for epoch bumps. Ref: chainguard-dev/pre-commit-hooks#25 Signed-off-by: Steve Beattie <steve.beattie@chainguard.dev>
Get latest chaingguard pre-commit hook to pick up the fix to ignore trailing comments after epoch numbers when checking for epoch bumps. Ref: chainguard-dev/pre-commit-hooks#25 Signed-off-by: Steve Beattie <steve.beattie@chainguard.dev>
The
epoch_sec()function will now ignore anything after the number in an epoch line.Addresses #24. 🤞