From f717d4f2e56db09447eeaf62e62f0e5ba826175d Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 27 Jan 2026 07:59:37 -0800 Subject: [PATCH] revert unnecessary change --- routers/web/repo/compare.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index eea91eaa84..6a5feb322a 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -533,26 +533,24 @@ 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()) - 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") - } + 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