Skip to content

Commit 2db933d

Browse files
committed
fix
1 parent 1c5c13a commit 2db933d

File tree

5 files changed

+13
-20
lines changed

5 files changed

+13
-20
lines changed

routers/web/repo/compare.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -569,19 +569,13 @@ func PrepareCompareDiff(
569569
ctx *context.Context,
570570
ci *common.CompareInfo,
571571
whitespaceBehavior git.TrustedCmdArgs,
572-
) bool {
573-
var (
574-
repo = ctx.Repo.Repository
575-
err error
576-
title string
577-
)
578-
579-
// Get diff information.
580-
ctx.Data["CommitRepoLink"] = ci.HeadRepo.Link()
581-
572+
) (nothingToCompare bool) {
573+
repo := ctx.Repo.Repository
582574
headCommitID := ci.CompareInfo.HeadCommitID
583575

576+
ctx.Data["CommitRepoLink"] = ci.HeadRepo.Link()
584577
ctx.Data["AfterCommitID"] = headCommitID
578+
ctx.Data["ExpandNewPrForm"] = ctx.FormBool("expand")
585579

586580
if (headCommitID == ci.CompareInfo.MergeBase && !ci.DirectComparison) ||
587581
headCommitID == ci.CompareInfo.BaseCommitID {
@@ -670,6 +664,7 @@ func PrepareCompareDiff(
670664
ctx.Data["Commits"] = commits
671665
ctx.Data["CommitCount"] = len(commits)
672666

667+
title := ci.HeadBranch
673668
if len(commits) == 1 {
674669
c := commits[0]
675670
title = strings.TrimSpace(c.UserCommit.Summary())
@@ -678,9 +673,8 @@ func PrepareCompareDiff(
678673
if len(body) > 1 {
679674
ctx.Data["content"] = strings.Join(body[1:], "\n")
680675
}
681-
} else {
682-
title = ci.HeadBranch
683676
}
677+
684678
if len(title) > 255 {
685679
var trailer string
686680
title, trailer = util.EllipsisDisplayStringX(title, 255)
@@ -745,8 +739,7 @@ func CompareDiff(ctx *context.Context) {
745739
ctx.Data["OtherCompareSeparator"] = "..."
746740
}
747741

748-
nothingToCompare := PrepareCompareDiff(ctx, ci,
749-
gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string)))
742+
nothingToCompare := PrepareCompareDiff(ctx, ci, gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string)))
750743
if ctx.Written() {
751744
return
752745
}

templates/repo/branch/list.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@
128128
{{svg "octicon-git-pull-request"}} {{ctx.Locale.Tr "repo.branch.included"}}
129129
</span>
130130
{{else if and (not .DBBranch.IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}
131-
<a href="{{$.RepoLink}}/compare/{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{PathEscape $.Owner.Name}}:{{end}}{{PathEscapeSegments .DBBranch.Name}}">
131+
<a href="{{$.RepoLink}}/compare/{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{PathEscape $.Owner.Name}}:{{end}}{{PathEscapeSegments .DBBranch.Name}}?expand=1">
132132
<button id="new-pull-request" class="ui compact basic button tw-mr-0">{{if $.CanPull}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}</button>
133133
</a>
134134
{{end}}
135135
{{else if and .LatestPullRequest.HasMerged .MergeMovedOn}}
136136
{{if and (not .DBBranch.IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}
137-
<a href="{{$.RepoLink}}/compare/{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{PathEscape $.Owner.Name}}:{{end}}{{PathEscapeSegments .DBBranch.Name}}">
137+
<a href="{{$.RepoLink}}/compare/{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{PathEscape $.Owner.Name}}:{{end}}{{PathEscapeSegments .DBBranch.Name}}?expand=1">
138138
<button id="new-pull-request" class="ui compact basic button tw-mr-0">{{if $.CanPull}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}</button>
139139
</a>
140140
{{end}}

templates/repo/code/recently_pushed_new_branches.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{$branchLink := HTMLFormat `<a href="%s">%s</a>` .BranchLink .BranchDisplayName}}
66
{{ctx.Locale.Tr "repo.pulls.recently_pushed_new_branches" $branchLink $timeSince}}
77
</div>
8-
<a role="button" class="ui compact green button tw-m-0" href="{{.BranchCompareURL}}">
8+
<a role="button" class="ui compact green button tw-m-0" href="{{QueryBuild .BranchCompareURL "expand" 1}}">
99
{{ctx.Locale.Tr "repo.pulls.compare_changes"}}
1010
</a>
1111
</div>

templates/repo/diff/compare.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@
205205
{{end}}
206206
</div>
207207
{{else if $allowCreatePR}}
208-
<div class="ui info message pullrequest-form-toggle {{if .Flash}}tw-hidden{{end}}">
208+
<div class="ui info message pullrequest-form-toggle {{if .ExpandNewPrForm}}tw-hidden{{end}}">
209209
<button class="ui button primary show-panel toggle" data-panel=".pullrequest-form-toggle, .pullrequest-form">{{ctx.Locale.Tr "repo.pulls.new"}}</button>
210210
</div>
211-
<div class="pullrequest-form {{if not .Flash}}tw-hidden{{end}}">
211+
<div class="pullrequest-form {{if not .ExpandNewPrForm}}tw-hidden{{end}}">
212212
{{template "repo/issue/new_form" .}}
213213
</div>
214214
{{end}}

templates/repo/view_content.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{{end}}
3131
{{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}}
3232
{{$compareLink := printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}}
33-
<a id="new-pull-request" role="button" class="ui compact basic button" href="{{$compareLink}}"
33+
<a id="new-pull-request" role="button" class="ui compact basic button" href="{{QueryBuild $compareLink "expand" 1}}"
3434
data-tooltip-content="{{if .PullRequestCtx.Allowed}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}">
3535
{{svg "octicon-git-pull-request"}}
3636
</a>

0 commit comments

Comments
 (0)