mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-13 06:46:03 +02:00
Fix bug when comparing there is diff but no commit
This commit is contained in:
parent
59f812bc1c
commit
84bbcf9844
@ -495,6 +495,7 @@ func PrepareCompareDiff(
|
||||
ctx.ServerError("GetDiffShortStat", err)
|
||||
return false
|
||||
}
|
||||
ctx.Data["IsNothingToCompare"] = diffShortStat.NumFiles == 0
|
||||
ctx.Data["DiffShortStat"] = diffShortStat
|
||||
ctx.Data["Diff"] = diff
|
||||
ctx.Data["DiffBlobExcerptData"] = &gitdiff.DiffBlobExcerptData{
|
||||
@ -532,24 +533,26 @@ func PrepareCompareDiff(
|
||||
return false
|
||||
}
|
||||
|
||||
commits, err := processGitCommits(ctx, ci.Commits)
|
||||
if err != nil {
|
||||
ctx.ServerError("processGitCommits", err)
|
||||
return false
|
||||
}
|
||||
ctx.Data["Commits"] = commits
|
||||
ctx.Data["CommitCount"] = len(commits)
|
||||
|
||||
title := ci.HeadRef.ShortName()
|
||||
if len(commits) == 1 {
|
||||
c := commits[0]
|
||||
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")
|
||||
if len(ci.Commits) > 0 {
|
||||
commits, err := processGitCommits(ctx, ci.Commits)
|
||||
if err != nil {
|
||||
ctx.ServerError("processGitCommits", err)
|
||||
return false
|
||||
}
|
||||
ctx.Data["Commits"] = commits
|
||||
if len(commits) == 1 {
|
||||
c := commits[0]
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.Data["CommitCount"] = len(ci.Commits)
|
||||
|
||||
if len(title) > 255 {
|
||||
var trailer string
|
||||
|
||||
@ -173,7 +173,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{$showDiffBox := and .CommitCount (not .IsNothingToCompare)}}
|
||||
{{if and .IsSigned .PageIsComparePull}}
|
||||
{{$allowCreatePR := and ($.CompareInfo.BaseRef.IsBranch) ($.CompareInfo.HeadRef.IsBranch) (not $.CompareInfo.DirectComparison) (or $.AllowEmptyPr (not .IsNothingToCompare))}}
|
||||
{{if .IsNothingToCompare}}
|
||||
@ -216,15 +215,17 @@
|
||||
</div>
|
||||
{{end}}
|
||||
{{else}}{{/* not singed-in or not for pull-request */}}
|
||||
{{if not .CommitCount}}
|
||||
{{if .IsNothingToCompare}}
|
||||
<div class="ui segment">{{ctx.Locale.Tr "repo.commits.nothing_to_compare"}}</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{if $showDiffBox}}
|
||||
{{if not .IsNothingToCompare}}
|
||||
<div class="ui container fluid padded tw-my-4">
|
||||
{{template "repo/commits_table" .}}
|
||||
{{if .CommitCount}}
|
||||
{{template "repo/commits_table" .}}
|
||||
{{end}}
|
||||
{{template "repo/diff/box" .}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user