summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-05-14 00:01:05 +0100
committerGitHub <noreply@github.com>2021-05-14 01:01:05 +0200
commitbbbe625343c8dbe216c4ba6f46b336ca0f7f2e47 (patch)
tree93ca3dd8c0e111b34d95e7b7e181ca1e16dd501b /contrib
parentd234d37aa8377f22882c630036824f7a25e1c2a4 (diff)
downloadgitea-bbbe625343c8dbe216c4ba6f46b336ca0f7f2e47.tar.gz
gitea-bbbe625343c8dbe216c4ba6f46b336ca0f7f2e47.zip
Only write config in environment-to-ini if there are changes (#15861)
* Only write config in environment-to-ini if there are changes Only write the new config in environment-to-ini if there are changes or the destination is not the same as the customconf. Fix #15719 Fix #15857 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/environment-to-ini/environment-to-ini.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go
index 74379e26af..aade251902 100644
--- a/contrib/environment-to-ini/environment-to-ini.go
+++ b/contrib/environment-to-ini/environment-to-ini.go
@@ -110,6 +110,8 @@ func runEnvironmentToIni(c *cli.Context) error {
}
cfg.NameMapper = ini.SnackCase
+ changed := false
+
prefix := c.String("prefix") + "__"
for _, kv := range os.Environ() {
@@ -143,15 +145,21 @@ func runEnvironmentToIni(c *cli.Context) error {
continue
}
}
+ oldValue := key.Value()
+ if !changed && oldValue != value {
+ changed = true
+ }
key.SetValue(value)
}
destination := c.String("out")
if len(destination) == 0 {
destination = setting.CustomConf
}
- err = cfg.SaveTo(destination)
- if err != nil {
- return err
+ if destination != setting.CustomConf || changed {
+ err = cfg.SaveTo(destination)
+ if err != nil {
+ return err
+ }
}
if c.Bool("clear") {
for _, kv := range os.Environ() {