From 28361a118478688367ae3a498406a9e90f41d349 Mon Sep 17 00:00:00 2001 From: brymut Date: Sun, 30 Nov 2025 17:43:00 +0300 Subject: [PATCH 1/3] fix: add diff blob excerpt data to pull review context --- routers/web/repo/pull_review.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go index f064058221ea6..f2d8d366076e4 100644 --- a/routers/web/repo/pull_review.go +++ b/routers/web/repo/pull_review.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/services/context" "code.gitea.io/gitea/services/context/upload" "code.gitea.io/gitea/services/forms" + "code.gitea.io/gitea/services/gitdiff" issue_service "code.gitea.io/gitea/services/issue" pull_service "code.gitea.io/gitea/services/pull" user_service "code.gitea.io/gitea/services/user" @@ -205,6 +206,12 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori return } ctx.Data["AfterCommitID"] = pullHeadCommitID + ctx.Data["DiffBlobExcerptData"] = &gitdiff.DiffBlobExcerptData{ + BaseLink: ctx.Repo.RepoLink + "/blob_excerpt", + PullIssueIndex: comment.Issue.Index, + DiffStyle: "unified", + AfterCommitID: pullHeadCommitID, + } ctx.Data["CanBlockUser"] = func(blocker, blockee *user_model.User) bool { return user_service.CanBlockUser(ctx, ctx.Doer, blocker, blockee) } From 3e4f43462ed8d188f0fb6bfde2f03701663add47 Mon Sep 17 00:00:00 2001 From: brymut Date: Wed, 3 Dec 2025 17:50:32 +0300 Subject: [PATCH 2/3] exclude blob excerpt expand --- routers/web/repo/pull_review.go | 7 ------- templates/repo/diff/section_unified.tmpl | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go index f2d8d366076e4..f064058221ea6 100644 --- a/routers/web/repo/pull_review.go +++ b/routers/web/repo/pull_review.go @@ -20,7 +20,6 @@ import ( "code.gitea.io/gitea/services/context" "code.gitea.io/gitea/services/context/upload" "code.gitea.io/gitea/services/forms" - "code.gitea.io/gitea/services/gitdiff" issue_service "code.gitea.io/gitea/services/issue" pull_service "code.gitea.io/gitea/services/pull" user_service "code.gitea.io/gitea/services/user" @@ -206,12 +205,6 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori return } ctx.Data["AfterCommitID"] = pullHeadCommitID - ctx.Data["DiffBlobExcerptData"] = &gitdiff.DiffBlobExcerptData{ - BaseLink: ctx.Repo.RepoLink + "/blob_excerpt", - PullIssueIndex: comment.Issue.Index, - DiffStyle: "unified", - AfterCommitID: pullHeadCommitID, - } ctx.Data["CanBlockUser"] = func(blocker, blockee *user_model.User) bool { return user_service.CanBlockUser(ctx, ctx.Doer, blocker, blockee) } diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index 908b14656e36e..a530fb5836d38 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -1,5 +1,5 @@ {{$file := .file}} -{{/* this tmpl is also used by the PR Conversation page, so the "AfterCommitID" and "DiffBlobExcerptData" may not exist */}} +{{/* this tmpl is also used by the PR Conversation page, so "DiffBlobExcerptData" may not exist */}} {{$diffBlobExcerptData := $.root.DiffBlobExcerptData}} @@ -12,10 +12,10 @@ {{range $k, $line := $section.Lines}} {{if eq .GetType 4}} - {{if $.root.AfterCommitID}} + {{if $diffBlobExcerptData}} {{$line.RenderBlobExcerptButtons $file.NameHash $diffBlobExcerptData}} {{else}} - {{/* for code file preview page or comment diffs on pull comment pages, do not show the expansion arrows */}} + {{/* when DiffBlobExcerptData is not available, do not show the expansion arrows */}} {{end}} {{else}} From 3d6c78592c6fc913a7e3bfacca405ce2af172971 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 4 Dec 2025 07:00:52 +0800 Subject: [PATCH 3/3] Update templates/repo/diff/section_unified.tmpl Signed-off-by: wxiaoguang --- templates/repo/diff/section_unified.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl index a530fb5836d38..6776198b7573e 100644 --- a/templates/repo/diff/section_unified.tmpl +++ b/templates/repo/diff/section_unified.tmpl @@ -15,7 +15,7 @@ {{if $diffBlobExcerptData}} {{$line.RenderBlobExcerptButtons $file.NameHash $diffBlobExcerptData}} {{else}} - {{/* when DiffBlobExcerptData is not available, do not show the expansion arrows */}} + {{/* when DiffBlobExcerptData is not available (code file preview, pull conversation diff comment), do not show the expansion arrows */}} {{end}} {{else}}