RenderCommitMessage renders commit message with special links.
(full bool, msg, urlPrefix string, metas map[string]string)
| 176 | |
| 177 | // RenderCommitMessage renders commit message with special links. |
| 178 | func 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 | |
| 202 | type Actioner interface { |
| 203 | GetOpType() int |
nothing calls this directly
no test coverage detected