otterdog icon indicating copy to clipboard operation
otterdog copied to clipboard

Strange diff for branch_protection_rule with square brackets in pattern

Open mbarbero opened this issue 6 months ago • 2 comments

When definining a branch protection rule with pattern [345].[x0123456789], the computed diff shows:

+  add branch_protection_rule[pattern="[345].", repository=vert.x] {

(from https://github.com/eclipse-vertx/.eclipsefdn/pull/15#issuecomment-2904490895)

My guess is that it's only a display issue, but would be great to verify

mbarbero avatar May 23 '25 14:05 mbarbero

As suspected, it is only a diff printing issue. The pattern in the created rule is correct after apply:

Image

mbarbero avatar May 23 '25 14:05 mbarbero

omg, we use now rich to format text for the console, and by coincidence, rich uses square brackets as markup tags:

header = header + f'\\[{key}="[bold]{self.get_key_value()}[/]"'

now rich will probably interpret [x0123456789] in some way as markup and not print it. So need to escape the text.

https://rich.readthedocs.io/en/stable/markup.html#escaping

netomi avatar May 26 '25 20:05 netomi

Thank you for the patch!

mbarbero avatar Jun 11 '25 11:06 mbarbero