summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElijah Oyekunle <eloyekunle@gmail.com>2019-01-16 22:50:11 +0100
committerJonas Franz <info@jonasfranz.software>2019-01-16 22:50:11 +0100
commit734834a6761d446a6e0dc25a104e8272143f6045 (patch)
tree20cc684584c04a045dc9371432c125b2d3508c49
parentc2dcb3514840d6807439f4b154a6802b00bf6d79 (diff)
downloadgitea-734834a6761d446a6e0dc25a104e8272143f6045.tar.gz
gitea-734834a6761d446a6e0dc25a104e8272143f6045.zip
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
-rw-r--r--routers/repo/pull.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index b38ba3bf56..36135084aa 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -722,8 +722,9 @@ func PrepareCompareDiff(
baseBranch, headBranch string) bool {
var (
- repo = ctx.Repo.Repository
- err error
+ repo = ctx.Repo.Repository
+ err error
+ title string
)
// Get diff information.
@@ -762,6 +763,20 @@ func PrepareCompareDiff(
prInfo.Commits = models.ParseCommitsWithStatus(prInfo.Commits, headRepo)
ctx.Data["Commits"] = prInfo.Commits
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["Reponame"] = headRepo.Name
ctx.Data["IsImageFile"] = headCommit.IsImageFile