Skip to content

Commit 88bde31

Browse files
GiteaBotearl-warren
authored andcommitted
Fix Actions being enabled accidentally (go-gitea#24802) (go-gitea#24810)
Backport go-gitea#24802 by @wolfogre Regression of go-gitea#24536. If the user doesn't explicitly disable Actions, it will be enabled. 1. Gitea will call `loadRepositoryFrom` before `loadActionsFrom`. https://github.com/go-gitea/gitea/blob/25d4f95df25dae5226e96e813dde87b071d9155e/modules/setting/setting.go#L234-L237 2. In `loadRepositoryFrom`, `rootCfg.Section("actions").Key("ENABLED").MustBool(true)` will set `actions.ENABLED` with `true`. https://github.com/go-gitea/gitea/blob/25d4f95df25dae5226e96e813dde87b071d9155e/modules/setting/repository.go#L313-L315 3. In `loadActionsFrom`, `rootCfg.Section("actions")` will get a section with Actions enabled. https://github.com/go-gitea/gitea/blob/25d4f95df25dae5226e96e813dde87b071d9155e/modules/setting/actions.go#L23-L26 Although the cause of the problem was using `true` by copy-paste mistake, it also surprised me that **`rootCfg.Section("actions").Key("ENABLED").MustBool(true)` doesn't only read, but also write.** Co-authored-by: Jason Song <i@wolfogre.com> (cherry picked from commit b369ed5)
1 parent 9bc4887 commit 88bde31

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/setting/repository.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ func loadRepositoryFrom(rootCfg ConfigProvider) {
307307
log.Fatal("Failed to map Repository.PullRequest settings: %v", err)
308308
}
309309

310-
if !rootCfg.Section("packages").Key("ENABLED").MustBool(true) {
310+
if !rootCfg.Section("packages").Key("ENABLED").MustBool(Packages.Enabled) {
311311
Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.packages")
312312
}
313313

314-
if !rootCfg.Section("actions").Key("ENABLED").MustBool(true) {
314+
if !rootCfg.Section("actions").Key("ENABLED").MustBool(Actions.Enabled) {
315315
Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.actions")
316316
}
317317

0 commit comments

Comments
 (0)