Skip to content

Commit e287b02

Browse files
wxiaoguangGiteaBot
authored andcommitted
Make environment-to-ini work with INSTALL_LOCK=true (go-gitea#25926)
Regression of go-gitea#25648, fix go-gitea#25924 Test: ```bash rm -f /tmp/example.ini /tmp/out.ini && \ echo "[security]" > /tmp/example.ini && \ echo "INSTALL_LOCK = true" >> /tmp/example.ini && \ GITEA__foo__bar=1 go run contrib/environment-to-ini/environment-to-ini.go --config=/tmp/example.ini --out=/tmp/out.ini && \ echo "==== example:" && \ cat /tmp/example.ini && \ echo "==== out:" && \ cat /tmp/out.ini ``` Output: ``` 2023/07/17 17:40:51 ...nvironment-to-ini.go:99:runEnvironmentToIni() [I] Settings saved to: "/tmp/out.ini" ==== example: [security] INSTALL_LOCK = true ==== out: [security] INSTALL_LOCK = true [foo] bar = 1 ```
1 parent 9159964 commit e287b02

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

contrib/environment-to-ini/environment-to-ini.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ func main() {
7575
}
7676

7777
func runEnvironmentToIni(c *cli.Context) error {
78+
// the config system may change the environment variables, so get a copy first, to be used later
79+
env := append([]string{}, os.Environ()...)
7880
setting.InitWorkPathAndCfgProvider(os.Getenv, setting.ArgWorkPathAndCustomConf{
7981
WorkPath: c.String("work-path"),
8082
CustomPath: c.String("custom-path"),
@@ -86,7 +88,7 @@ func runEnvironmentToIni(c *cli.Context) error {
8688
log.Fatal("Failed to load custom conf '%s': %v", setting.CustomConf, err)
8789
}
8890

89-
changed := setting.EnvironmentToConfig(cfg, os.Environ())
91+
changed := setting.EnvironmentToConfig(cfg, env)
9092

9193
// try to save the config file
9294
destination := c.String("out")

0 commit comments

Comments
 (0)