mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Fix Actions being enabled accidentally (#24802)
Regression of #24536. If the user doesn't explicitly disable Actions, it will be enabled. 1. Gitea will call `loadRepositoryFrom` before `loadActionsFrom`.25d4f95df2/modules/setting/setting.go (L234-L237)2. In `loadRepositoryFrom`, `rootCfg.Section("actions").Key("ENABLED").MustBool(true)` will set `actions.ENABLED` with `true`.25d4f95df2/modules/setting/repository.go (L313-L315)3. In `loadActionsFrom`, `rootCfg.Section("actions")` will get a section with Actions enabled.25d4f95df2/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.**
This commit is contained in:
		@@ -306,11 +306,11 @@ func loadRepositoryFrom(rootCfg ConfigProvider) {
 | 
				
			|||||||
		log.Fatal("Failed to map Repository.PullRequest settings: %v", err)
 | 
							log.Fatal("Failed to map Repository.PullRequest settings: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if !rootCfg.Section("packages").Key("ENABLED").MustBool(true) {
 | 
						if !rootCfg.Section("packages").Key("ENABLED").MustBool(Packages.Enabled) {
 | 
				
			||||||
		Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.packages")
 | 
							Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.packages")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if !rootCfg.Section("actions").Key("ENABLED").MustBool(true) {
 | 
						if !rootCfg.Section("actions").Key("ENABLED").MustBool(Actions.Enabled) {
 | 
				
			||||||
		Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.actions")
 | 
							Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.actions")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user