Skip to content

Commit bf01131

Browse files
committed
Reinstate most of commit 09304db
1 parent 86e2789 commit bf01131

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

services/pull/pull.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,22 +564,35 @@ func GetSquashMergeCommitMessages(pr *models.PullRequest) string {
564564
return ""
565565
}
566566

567+
maxSize := setting.Repository.PullRequest.DefaultMergeMessageSize
568+
567569
posterSig := pr.Issue.Poster.NewGitSig().String()
568570

569571
authorsMap := map[string]bool{}
570572
authors := make([]string, 0, list.Len())
571573
stringBuilder := strings.Builder{}
572574

573-
stringBuilder.WriteString(pr.Issue.Content)
574-
if stringBuilder.Len() > 0 {
575-
stringBuilder.WriteRune('\n')
576-
stringBuilder.WriteRune('\n')
577-
}
578-
579575
// commits list is in reverse chronological order
580576
element := list.Back()
581577
for element != nil {
582578
commit := element.Value.(*git.Commit)
579+
580+
if maxSize < 0 || stringBuilder.Len() < maxSize {
581+
toWrite := []byte(commit.CommitMessage)
582+
if len(toWrite) > maxSize-stringBuilder.Len() && maxSize > -1 {
583+
toWrite = append(toWrite[:maxSize-stringBuilder.Len()], "..."...)
584+
}
585+
if _, err := stringBuilder.Write(toWrite); err != nil {
586+
log.Error("Unable to write commit message Error: %v", err)
587+
return ""
588+
}
589+
590+
if _, err := stringBuilder.WriteRune('\n'); err != nil {
591+
log.Error("Unable to write commit message Error: %v", err)
592+
return ""
593+
}
594+
}
595+
583596
authorString := commit.Author.String()
584597
if !authorsMap[authorString] && authorString != posterSig {
585598
authors = append(authors, authorString)

0 commit comments

Comments
 (0)