diff options
Diffstat (limited to 'lib/templates/functions.go')
-rw-r--r-- | lib/templates/functions.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/templates/functions.go b/lib/templates/functions.go index 2e551594..f6cb0df4 100644 --- a/lib/templates/functions.go +++ b/lib/templates/functions.go @@ -1,6 +1,7 @@ package templates import ( + "bufio" "bytes" "fmt" "os" @@ -181,6 +182,23 @@ func join(sep string, elems []string) string { return strings.Join(elems, sep) } +// removes a signature from the piped in message +func trimSignature(message string) string { + var res strings.Builder + + input := bufio.NewScanner(strings.NewReader(message)) + + for input.Scan() { + line := input.Text() + if line == "-- " { + break + } + res.WriteString(line) + res.WriteRune('\n') + } + return res.String() +} + var templateFuncs = template.FuncMap{ "quote": quote, "wrapText": wrapText, @@ -196,4 +214,5 @@ var templateFuncs = template.FuncMap{ "humanReadable": humanReadable, "cwd": cwd, "join": join, + "trimSignature": trimSignature, } |