Skip to content

Commit

Permalink
Add template to pr automation regexes
Browse files Browse the repository at this point in the history
Will allow some more complex parameterized replacements
  • Loading branch information
michaeljguarino committed Nov 22, 2024
1 parent be7e5d6 commit 592775d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/pr/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ func processRegexReplacements(replacements []RegexReplacement, ctx map[string]in
}

replaceFunc := func(data []byte) ([]byte, error) {
r, err := regexp.Compile(replacement.Regex)
rx, err := templateReplacement([]byte(replacement.Regex), ctx)
if err != nil {
rx = []byte(replacement.Regex)
}

r, err := regexp.Compile(string(rx))
if err != nil {
return data, err
}

return r.ReplaceAll(data, replaceWith), nil
}

Expand Down

0 comments on commit 592775d

Please sign in to comment.