mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
fix(template): address regression in string functions for template engine (#142)
It appears that `Sprig` flips the inputs of the `contains`, `hasPrefix`, `replace` and `hasSuffix` `strings` methods. This appears to be the cause of the regression. See: https://github.com/Masterminds/sprig/blob/master/functions.go#L149-L152 This results in a regression against the previous implementations of the template functions. Signed-off-by: Derek Smith <derek@clokwork.net>
This commit is contained in:
parent
7cc56b1256
commit
fdd421b057
2 changed files with 23 additions and 2 deletions
|
|
@ -340,6 +340,13 @@ func (gen *Generator) render(w io.Writer, unreleased *Unreleased, versions []*Ve
|
|||
pad := strings.Repeat(" ", n)
|
||||
return pad + strings.ReplaceAll(s, "\n", "\n"+pad)
|
||||
},
|
||||
// While Sprig provides these functions, they change the standard input
|
||||
// order which leads to a regression. For an example see:
|
||||
// https://github.com/Masterminds/sprig/blob/master/functions.go#L149
|
||||
"contains": strings.Contains,
|
||||
"hasPrefix": strings.HasPrefix,
|
||||
"hasSuffix": strings.HasSuffix,
|
||||
"replace": strings.Replace,
|
||||
}
|
||||
|
||||
fname := filepath.Base(gen.config.Template)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue