diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index fddfc4a63a89..f00b35aaad86 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -567,6 +567,15 @@ func PrepareCompareDiff( } else { title = headBranch } + if len(title) > 255 { + if ctx.Data["content"] != nil { + ctx.Data["content"] = fmt.Sprintf("...%s\n\n%s", title[252:], ctx.Data["content"]) + } else { + ctx.Data["content"] = "..." + title[252:] + "\n" + } + title = title[:252] + "..." + } + ctx.Data["title"] = title ctx.Data["Username"] = headUser.Name ctx.Data["Reponame"] = headRepo.Name diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index a29979964777..6ef5a09309b7 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1001,10 +1001,14 @@ func CompareAndPullRequestPost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.pulls.compare_changes") ctx.Data["PageIsComparePull"] = true ctx.Data["IsDiffCompare"] = true + ctx.Data["IsRepoToolbarCommits"] = true + ctx.Data["RequireTribute"] = true + ctx.Data["RequireSimpleMDE"] = true ctx.Data["RequireHighlightJS"] = true ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled upload.AddUploadContext(ctx, "comment") + ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWrite(models.UnitTypePullRequests) var ( repo = ctx.Repo.Repository @@ -1037,6 +1041,12 @@ func CompareAndPullRequestPost(ctx *context.Context) { return } + if len(form.Title) > 255 { + form.Content = "..." + form.Title[252:] + "\n\n" + form.Content + form.Title = form.Title[:252] + "..." + } + middleware.AssignForm(form, ctx.Data) + ctx.HTML(http.StatusOK, tplCompareDiff) return } diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 7959ef7bb517..2beca579601f 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -176,10 +176,10 @@ {{if .IsNothingToCompare}} {{if and $.IsSigned $.AllowEmptyPr (not .Repository.IsArchived) }}
{{.i18n.Tr "repo.pulls.nothing_to_compare_and_allow_empty_pr"}}
-
+
- {{else}} {{if and $.IsSigned (not .Repository.IsArchived)}} -
+
{{else if .Repository.IsArchived}} @@ -201,7 +201,7 @@
{{end}} {{if $.IsSigned}} -