MCPcopy Create free account
hub / github.com/gogs/gogs / RenderCommitMessage

Function RenderCommitMessage

internal/template/template.go:178–200  ·  view source on GitHub ↗

RenderCommitMessage renders commit message with special links.

(full bool, msg, urlPrefix string, metas map[string]string)

Source from the content-addressed store, hash-verified

176
177// RenderCommitMessage renders commit message with special links.
178func RenderCommitMessage(full bool, msg, urlPrefix string, metas map[string]string) string {
179 cleanMsg := template.HTMLEscapeString(msg)
180 fullMessage := string(markup.RenderIssueIndexPattern([]byte(cleanMsg), urlPrefix, metas))
181 msgLines := strings.Split(strings.TrimSpace(fullMessage), "\n")
182 numLines := len(msgLines)
183 if numLines == 0 {
184 return ""
185 } else if !full {
186 return msgLines[0]
187 } else if numLines == 1 || (numLines >= 2 && msgLines[1] == "") {
188 // First line is a header, standalone or followed by empty line
189 header := fmt.Sprintf("<h3>%s</h3>", msgLines[0])
190 if numLines >= 2 {
191 fullMessage = header + fmt.Sprintf("\n<pre>%s</pre>", strings.Join(msgLines[2:], "\n"))
192 } else {
193 fullMessage = header
194 }
195 } else {
196 // Non-standard git message, there is no header line
197 fullMessage = fmt.Sprintf("<h4>%s</h4>", strings.Join(msgLines, "<br>"))
198 }
199 return fullMessage
200}
201
202type Actioner interface {
203 GetOpType() int

Callers

nothing calls this directly

Calls 3

RenderIssueIndexPatternFunction · 0.92
stringFunction · 0.85
SplitMethod · 0.80

Tested by

no test coverage detected