Enforce git config on startup (#383)

This commit is contained in:
Thomas Miceli
2024-11-21 11:23:57 +01:00
committed by GitHub
parent 00e3d09cc5
commit 5994cd6ccd
3 changed files with 28 additions and 3 deletions

23
internal/git/config.go Normal file
View File

@ -0,0 +1,23 @@
package git
import "os/exec"
func InitGitConfig() error {
configs := map[string]string{
"receive.advertisePushOptions": "true",
"safe.directory": "*",
}
for key, value := range configs {
if err := setGitConfig(key, value); err != nil {
return err
}
}
return nil
}
func setGitConfig(key, value string) error {
cmd := exec.Command("git", "config", "--global", key, value)
return cmd.Run()
}