opengist/internal/git/config.go

24 lines
426 B
Go
Raw Normal View History

2024-11-21 10:23:57 +00:00
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()
}