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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user