Repository navigation
Conversation
The Block fact and files.block put the marker inside an awk regex, so a marker with regex characters like `(`, `.` or `*` was never found and the block was appended again on every run. A marker with `/` or `'` broke the awk command. Pass the markers to awk as arguments and match them with index(), so they are always plain text. Fixes pyinfra-dev#2111. Based on pyinfra-dev#2112 by sniwas, which Fizzadar approved. Co-authored-by: sniwas <122344020+sniwas@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #2111. Picks up #2112 by @sniwas (approved, then closed by its author), with the same approach.
Why
files.blockand thefiles.Blockfact put the marker inside an awk/regex/. So a marker with regex characters like(,.or*was never found, and the block was added again on every run. A marker with/or'broke the awk command completely.Changes
index(), so they are always plain text. This covers all 3 places: the fact, updating a block, and removing a block.markeris matched as plain text.(block),/and'.Testing
@localtwice. Before: each run adds another copy of the block (3 runs, 3 blocks). After: 1 block, and later runs are "No changes". Update and remove also work.Note: files already hit by this bug have the block more than once. The fix finds all copies, so
present=Falseremoves them all and you can then add the block again.3.xat this time)scripts/dev-test.sh)scripts/dev-lint.sh)AI disclosure: I used Claude Code to write the code and tests, and I reviewed and understand all of it.