0
0
mirror of https://github.com/thegeeklab/wp-git-clone.git synced 2024-11-13 23:10:41 +00:00
wp-git-clone/git/config.go

71 lines
1.2 KiB
Go
Raw Normal View History

2023-12-22 23:59:23 +00:00
package git
import (
"fmt"
"strconv"
"golang.org/x/sys/execabs"
)
// ConfigSSLVerify disables globally the git ssl verification.
func ConfigSSLVerify(repo Repository) *execabs.Cmd {
args := []string{
"config",
"--global",
2023-12-22 23:59:23 +00:00
"http.sslVerify",
strconv.FormatBool(!repo.InsecureSkipSSLVerify),
2023-12-22 23:59:23 +00:00
}
return execabs.Command(
gitBin,
args...,
)
}
// ConfigSafeDirectory disables globally the git ssl verification.
func ConfigSafeDirectory(repo Repository) *execabs.Cmd {
args := []string{
"config",
"--global",
2023-12-22 23:59:23 +00:00
"--replace-all",
"safe.directory",
repo.SafeDirectory,
}
return execabs.Command(
gitBin,
args...,
)
}
// ConfigRemapSubmodule returns a git command that, when executed configures git to
// remap submodule urls.
func ConfigRemapSubmodule(name, url string) *execabs.Cmd {
args := []string{
"config",
"--global",
2023-12-22 23:59:23 +00:00
fmt.Sprintf("submodule.%s.url", name),
url,
}
return execabs.Command(
gitBin,
args...,
)
}
// ConfigSSHCommand sets custom SSH key.
func ConfigSSHCommand(sshKey string) *execabs.Cmd {
args := []string{
"config",
"--global",
2023-12-22 23:59:23 +00:00
"core.sshCommand",
"ssh -i " + sshKey,
}
return execabs.Command(
gitBin,
args...,
)
}