Add Default Pull Request Title (#5735)

* add default PR title
Set default PR title to commit summary if there's a single commit on the head branch, else set it to the head branch name

* set default PR description
If there's a single commit on the head branch, and it's multiline, then set it as the default PR description
pull/5382/head
Elijah Oyekunle 6 years ago committed by Jonas Franz
parent c2dcb35148
commit 734834a676
  1. 15
      routers/repo/pull.go

@ -724,6 +724,7 @@ func PrepareCompareDiff(
var ( var (
repo = ctx.Repo.Repository repo = ctx.Repo.Repository
err error err error
title string
) )
// Get diff information. // Get diff information.
@ -762,6 +763,20 @@ func PrepareCompareDiff(
prInfo.Commits = models.ParseCommitsWithStatus(prInfo.Commits, headRepo) prInfo.Commits = models.ParseCommitsWithStatus(prInfo.Commits, headRepo)
ctx.Data["Commits"] = prInfo.Commits ctx.Data["Commits"] = prInfo.Commits
ctx.Data["CommitCount"] = prInfo.Commits.Len() ctx.Data["CommitCount"] = prInfo.Commits.Len()
if prInfo.Commits.Len() == 1 {
c := prInfo.Commits.Front().Value.(models.SignCommitWithStatuses)
title = strings.TrimSpace(c.UserCommit.Summary())
body := strings.Split(strings.TrimSpace(c.UserCommit.Message()), "\n")
if len(body) > 1 {
ctx.Data["content"] = strings.Join(body[1:], "\n")
}
} else {
title = headBranch
}
ctx.Data["title"] = title
ctx.Data["Username"] = headUser.Name ctx.Data["Username"] = headUser.Name
ctx.Data["Reponame"] = headRepo.Name ctx.Data["Reponame"] = headRepo.Name
ctx.Data["IsImageFile"] = headCommit.IsImageFile ctx.Data["IsImageFile"] = headCommit.IsImageFile

Loading…
Cancel
Save