mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-21 08:50:51 +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)
|
ctx.ServerError("GetDiffShortStat", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
ctx.Data["IsNothingToCompare"] = diffShortStat.NumFiles == 0
|
||||||
ctx.Data["DiffShortStat"] = diffShortStat
|
ctx.Data["DiffShortStat"] = diffShortStat
|
||||||
ctx.Data["Diff"] = diff
|
ctx.Data["Diff"] = diff
|
||||||
ctx.Data["DiffBlobExcerptData"] = &gitdiff.DiffBlobExcerptData{
|
ctx.Data["DiffBlobExcerptData"] = &gitdiff.DiffBlobExcerptData{
|
||||||
@ -532,24 +533,26 @@ func PrepareCompareDiff(
|
|||||||
return false
|
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()
|
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(ci.Commits) > 0 {
|
||||||
if len(body) > 1 {
|
commits, err := processGitCommits(ctx, ci.Commits)
|
||||||
ctx.Data["content"] = strings.Join(body[1:], "\n")
|
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 {
|
if len(title) > 255 {
|
||||||
var trailer string
|
var trailer string
|
||||||
|
|||||||
@ -173,7 +173,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{$showDiffBox := and .CommitCount (not .IsNothingToCompare)}}
|
|
||||||
{{if and .IsSigned .PageIsComparePull}}
|
{{if and .IsSigned .PageIsComparePull}}
|
||||||
{{$allowCreatePR := and ($.CompareInfo.BaseRef.IsBranch) ($.CompareInfo.HeadRef.IsBranch) (not $.CompareInfo.DirectComparison) (or $.AllowEmptyPr (not .IsNothingToCompare))}}
|
{{$allowCreatePR := and ($.CompareInfo.BaseRef.IsBranch) ($.CompareInfo.HeadRef.IsBranch) (not $.CompareInfo.DirectComparison) (or $.AllowEmptyPr (not .IsNothingToCompare))}}
|
||||||
{{if .IsNothingToCompare}}
|
{{if .IsNothingToCompare}}
|
||||||
@ -216,15 +215,17 @@
|
|||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}{{/* not singed-in or not for pull-request */}}
|
{{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>
|
<div class="ui segment">{{ctx.Locale.Tr "repo.commits.nothing_to_compare"}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{if $showDiffBox}}
|
{{if not .IsNothingToCompare}}
|
||||||
<div class="ui container fluid padded tw-my-4">
|
<div class="ui container fluid padded tw-my-4">
|
||||||
{{template "repo/commits_table" .}}
|
{{if .CommitCount}}
|
||||||
|
{{template "repo/commits_table" .}}
|
||||||
|
{{end}}
|
||||||
{{template "repo/diff/box" .}}
|
{{template "repo/diff/box" .}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user