Hi,
We have a use case where we need to redact code between 2 lines for files with a certain extension like .js or html.
For example:
Before -
foo
//start
some
code
needing
removal
//end
bar
After -
foo
bar
We came across Copybara and it had a way to do this simply by using core.replace in the transformations with core.workflow which we thought was perfect for our use case.
However we wanted this to be done in the same repo (some crazy requirement which unfortunately can't be changed :( ). For example, the main branch would have the full code and another branch called redact would have the redacted code.
Is it possible to do that?
If yes (which would be awesome! :) ) what would the copy.bara.sky file look like?
Currently this is what we have and we are unable to get it to work:
core.workflow(
name = "push",
origin = git.origin(
url = "some url",
ref = "main",
),
destination = git.destination(
url = "same url as origin",
fetch = "redact"
push = "redact",
),
origin_files = glob(["**"]),
authoring = authoring.pass_thru("Name <na...@example.com>"),
transformations = [
core.replace(
before = "${x}",
after = "",
multiline = True,
regex_groups = {
"x": "(?m)^.*start [\\w\\W]*?end .*$\\n",
},
paths = glob(["**.html"]),
)
]
)
Any help is HIGHLY appreciated.
Thanks.