diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 6a5feb322a..366637e544 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -448,7 +448,8 @@ func PrepareCompareDiff( if (headCommitID == ci.MergeBase && !ci.DirectComparison()) || headCommitID == ci.BaseCommitID { - ctx.Data["IsNothingToCompare"] = true + ctx.Data["CommitCount"] = 0 + ctx.Data["DiffNotAvailable"] = true if unit, err := repo.GetUnit(ctx, unit.TypePullRequests); err == nil { config := unit.PullRequestsConfig() @@ -495,7 +496,6 @@ 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{ diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 8dd21dd480..9f0e68d387 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -174,8 +174,8 @@ {{if and .IsSigned .PageIsComparePull}} - {{$allowCreatePR := and ($.CompareInfo.BaseRef.IsBranch) ($.CompareInfo.HeadRef.IsBranch) (not $.CompareInfo.DirectComparison) (or $.AllowEmptyPr (not .IsNothingToCompare))}} - {{if .IsNothingToCompare}} + {{$allowCreatePR := and ($.CompareInfo.BaseRef.IsBranch) ($.CompareInfo.HeadRef.IsBranch) (not $.CompareInfo.DirectComparison) (or $.AllowEmptyPr (not .DiffNotAvailable))}} + {{if .DiffNotAvailable}}