Refactor compare diff/pull page (1) (#37481)

1. Rename CompareInfo.MergeBase to CompareBase, it is not merge base
2. Remove unused template variables `ctx.Data["Username"]` and
`ctx.Data["Reponame"]`
3. Decouple some template variable accesses, use typed struct

---------

Co-authored-by: Nicolas <bircni@icloud.com>
This commit is contained in:
wxiaoguang
2026-04-30 02:32:46 +08:00
committed by GitHub
parent 184ce17167
commit 2b2ec6af85
9 changed files with 115 additions and 116 deletions
+17
View File
@@ -9,6 +9,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/optional"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/context"
"code.gitea.io/gitea/services/gitdiff"
@@ -80,6 +81,14 @@ func SetWhitespaceBehavior(ctx *context.Context) {
}
}
func GetWhitespaceBehavior(ctx *context.Context) string {
behavior, ok := ctx.Data["WhitespaceBehavior"].(string)
if !ok {
setting.PanicInDevOrTesting("WhitespaceBehavior is not set in context data or is not a string")
}
return behavior
}
// SetShowOutdatedComments set the show outdated comments option as context variable
func SetShowOutdatedComments(ctx *context.Context) {
showOutdatedCommentsValue := ctx.FormString("show-outdated")
@@ -95,3 +104,11 @@ func SetShowOutdatedComments(ctx *context.Context) {
}
ctx.Data["ShowOutdatedComments"], _ = strconv.ParseBool(showOutdatedCommentsValue)
}
func GetShowOutdatedComments(ctx *context.Context) bool {
show, ok := ctx.Data["ShowOutdatedComments"].(bool)
if !ok {
setting.PanicInDevOrTesting("ShowOutdatedComments is not set in context data or is not a bool")
}
return show
}