diff --git a/routers/repo/pull.go b/routers/repo/pull.go index b38ba3bf56d..36135084aaa 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