@@ -339,33 +339,37 @@ func RenderCommitMessageLink(msg, urlPrefix, urlDefault string, metas map[string
339
339
// the provided default url, handling for special links without email to links.
340
340
func RenderCommitMessageLinkSubject (msg , urlPrefix , urlDefault string , metas map [string ]string ) template.HTML {
341
341
cleanMsg := template .HTMLEscapeString (msg )
342
+
343
+ msgLines := strings .Split (strings .TrimSpace (string (cleanMsg )), "\n " )
344
+ if len (msgLines ) == 0 {
345
+ return template .HTML ("" )
346
+ }
347
+
342
348
// we can safely assume that it will not return any error, since there
343
349
// shouldn't be any special HTML.
344
- fullMessage , err := markup .RenderCommitMessageSubject ([]byte (cleanMsg ), urlPrefix , urlDefault , metas )
350
+ renderedMessage , err := markup .RenderCommitMessageSubject ([]byte (msgLines [ 0 ] ), urlPrefix , urlDefault , metas )
345
351
if err != nil {
346
352
log .Error ("RenderCommitMessageSubject: %v" , err )
347
- return ""
348
- }
349
- msgLines := strings .Split (strings .TrimSpace (string (fullMessage )), "\n " )
350
- if len (msgLines ) == 0 {
351
353
return template .HTML ("" )
352
354
}
353
- return template .HTML (msgLines [ 0 ] )
355
+ return template .HTML (renderedMessage )
354
356
}
355
357
356
358
// RenderCommitBody extracts the body of a commit message without its title.
357
359
func RenderCommitBody (msg , urlPrefix string , metas map [string ]string ) template.HTML {
358
360
cleanMsg := template .HTMLEscapeString (msg )
359
- fullMessage , err := markup .RenderCommitMessage ([]byte (cleanMsg ), urlPrefix , "" , metas )
361
+
362
+ msgLines := strings .Split (strings .TrimSpace (string (cleanMsg )), "\n " )
363
+ if len (msgLines ) <= 1 {
364
+ return template .HTML ("" )
365
+ }
366
+
367
+ renderedMessage , err := markup .RenderCommitMessage ([]byte (strings .Join (msgLines [1 :], "\n " )), urlPrefix , "" , metas )
360
368
if err != nil {
361
369
log .Error ("RenderCommitMessage: %v" , err )
362
370
return ""
363
371
}
364
- body := strings .Split (strings .TrimSpace (string (fullMessage )), "\n " )
365
- if len (body ) == 0 {
366
- return template .HTML ("" )
367
- }
368
- return template .HTML (strings .Join (body [1 :], "\n " ))
372
+ return template .HTML (renderedMessage )
369
373
}
370
374
371
375
// RenderNote renders the contents of a git-notes file as a commit message.
0 commit comments