From f55878cd5a2351cac973d13db92d940f6fbb7224 Mon Sep 17 00:00:00 2001 From: Sondre Nilsen Date: Mon, 27 Nov 2017 22:48:38 +0100 Subject: [PATCH] Add/fix comments and run make fmt --- modules/templates/helper.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 33c814a965ee5..28fbdc8d2197a 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -108,10 +108,10 @@ func NewFuncMap() []template.FuncMap { "EscapePound": func(str string) string { return strings.NewReplacer("%", "%25", "#", "%23", " ", "%20", "?", "%3F").Replace(str) }, - "RenderCommitMessage": RenderCommitMessage, - "RenderCommitMessageLink": RenderCommitMessageLink, - "RenderCommitBody": RenderCommitBody, - "IsMultilineCommitMessage": IsMultilineCommitMessage, + "RenderCommitMessage": RenderCommitMessage, + "RenderCommitMessageLink": RenderCommitMessageLink, + "RenderCommitBody": RenderCommitBody, + "IsMultilineCommitMessage": IsMultilineCommitMessage, "ThemeColorMetaTag": func() string { return setting.UI.ThemeColorMetaTag }, @@ -280,24 +280,25 @@ func renderCommitMessage(msg string, opts markup.RenderIssueIndexPatternOptions) return template.HTML(msgLines[0]) } -// Extracts the body of a commit message without its title, and makes it XSS-safe +// RenderCommitBody extracts the body of a commit message without its title. func RenderCommitBody(msg, urlPrefix string, metas map[string]string) template.HTML { return renderCommitBody(msg, markup.RenderIssueIndexPatternOptions{ - URLPrefix: urlPrefix, - Metas: metas, + URLPrefix: urlPrefix, + Metas: metas, }) } func renderCommitBody(msg string, opts markup.RenderIssueIndexPatternOptions) template.HTML { cleanMsg := template.HTMLEscapeString(msg) fullMessage := string(markup.RenderIssueIndexPattern([]byte(cleanMsg), opts)) - body := strings.Split(strings.TrimSpace(fullMessage),"\n") + body := strings.Split(strings.TrimSpace(fullMessage), "\n") if len(body) == 0 { return template.HTML("") } return template.HTML(strings.Join(body[1:], "\n")) } +// IsMultilineCommitMessage checks to see if a commit message contains multiple lines. func IsMultilineCommitMessage(msg string) bool { return strings.Count(strings.TrimSpace(msg), "\n") > 1 }