Skip to content

Commit 6f5eb18

Browse files
committed
Append to existing PR description trailer section
If the existing PR description message already contains a trailer section (e.g. Signed-off-by: ), append to it instead of creating a new trailer section.
1 parent d0bd605 commit 6f5eb18

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

services/pull/pull.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"bytes"
1010
"context"
1111
"fmt"
12+
"regexp"
1213
"strings"
1314
"time"
1415

@@ -573,7 +574,10 @@ func GetSquashMergeCommitMessages(pr *models.PullRequest) string {
573574
stringBuilder.WriteString(pr.Issue.Content)
574575
if stringBuilder.Len() > 0 {
575576
stringBuilder.WriteRune('\n')
576-
stringBuilder.WriteRune('\n')
577+
commitMessageTrailersPattern := regexp.MustCompile(`(^|.*\n\n)([\w-]+: [^\n]+)(\n[\w-]+: [^\n]+)*$`)
578+
if !commitMessageTrailersPattern.MatchString(pr.Issue.Content) {
579+
stringBuilder.WriteRune('\n')
580+
}
577581
}
578582

579583
// commits list is in reverse chronological order

0 commit comments

Comments
 (0)