Skip to content

Commit 2564c15

Browse files
authored
Remove some unnecessary template helpers (#33069)
DisableGitHooks and DisableImportLocal are only used when editing a user, so only set them in `editUserCommon`
1 parent 57eb9d0 commit 2564c15

File tree

10 files changed

+184
-187
lines changed

10 files changed

+184
-187
lines changed

modules/setting/security.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import (
1313
"code.gitea.io/gitea/modules/log"
1414
)
1515

16+
// Security settings
17+
1618
var (
17-
// Security settings
1819
InstallLock bool
1920
SecretKey string
2021
InternalToken string // internal access token
@@ -27,7 +28,7 @@ var (
2728
ReverseProxyTrustedProxies []string
2829
MinPasswordLength int
2930
ImportLocalPaths bool
30-
DisableGitHooks bool
31+
DisableGitHooks = true
3132
DisableWebhooks bool
3233
OnlyAllowPushIfGiteaEnvironmentSet bool
3334
PasswordComplexity []string

modules/templates/helper.go

-6
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,9 @@ func NewFuncMap() template.FuncMap {
131131
"EnableTimetracking": func() bool {
132132
return setting.Service.EnableTimetracking
133133
},
134-
"DisableGitHooks": func() bool {
135-
return setting.DisableGitHooks
136-
},
137134
"DisableWebhooks": func() bool {
138135
return setting.DisableWebhooks
139136
},
140-
"DisableImportLocal": func() bool {
141-
return !setting.ImportLocalPaths
142-
},
143137
"UserThemeName": userThemeName,
144138
"NotificationSettings": func() map[string]any {
145139
return map[string]any{

routers/web/admin/users.go

+2
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ func editUserCommon(ctx *context.Context) {
313313
ctx.Data["PageIsAdminUsers"] = true
314314
ctx.Data["DisableRegularOrgCreation"] = setting.Admin.DisableRegularOrgCreation
315315
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
316+
ctx.Data["DisableGitHooks"] = setting.DisableGitHooks
317+
ctx.Data["DisableImportLocal"] = !setting.ImportLocalPaths
316318
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
317319
ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx)
318320
}

templates/admin/user/edit.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@
128128
<input name="restricted" type="checkbox" {{if .User.IsRestricted}}checked{{end}}>
129129
</div>
130130
</div>
131-
<div class="inline field {{if DisableGitHooks}}tw-hidden{{end}}">
131+
<div class="inline field {{if .DisableGitHooks}}tw-hidden{{end}}">
132132
<div class="ui checkbox" data-tooltip-content="{{ctx.Locale.Tr "admin.users.allow_git_hook_tooltip"}}">
133133
<label><strong>{{ctx.Locale.Tr "admin.users.allow_git_hook"}}</strong></label>
134-
<input name="allow_git_hook" type="checkbox" {{if .User.CanEditGitHook}}checked{{end}} {{if DisableGitHooks}}disabled{{end}}>
134+
<input name="allow_git_hook" type="checkbox" {{if .User.CanEditGitHook}}checked{{end}} {{if .DisableGitHooks}}disabled{{end}}>
135135
</div>
136136
</div>
137-
<div class="inline field {{if or (DisableImportLocal) (.DisableMigrations)}}tw-hidden{{end}}">
137+
<div class="inline field {{if or (.DisableImportLocal) (.DisableMigrations)}}tw-hidden{{end}}">
138138
<div class="ui checkbox">
139139
<label><strong>{{ctx.Locale.Tr "admin.users.allow_import_local"}}</strong></label>
140-
<input name="allow_import_local" type="checkbox" {{if .User.CanImportLocal}}checked{{end}} {{if DisableImportLocal}}disabled{{end}}>
140+
<input name="allow_import_local" type="checkbox" {{if .User.CanImportLocal}}checked{{end}} {{if .DisableImportLocal}}disabled{{end}}>
141141
</div>
142142
</div>
143143
{{if not .DisableRegularOrgCreation}}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/bin/bash
2-
3-
echo Hello, World!
2+
echo "TestGitHookScript"

0 commit comments

Comments
 (0)