mirror of
https://github.com/thegeeklab/wp-git-clone.git
synced 2024-11-24 23:10:40 +00:00
71 lines
1.2 KiB
Go
71 lines
1.2 KiB
Go
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",
|
|
"http.sslVerify",
|
|
strconv.FormatBool(!repo.InsecureSkipSSLVerify),
|
|
}
|
|
|
|
return execabs.Command(
|
|
gitBin,
|
|
args...,
|
|
)
|
|
}
|
|
|
|
// ConfigSafeDirectory disables globally the git ssl verification.
|
|
func ConfigSafeDirectory(repo Repository) *execabs.Cmd {
|
|
args := []string{
|
|
"config",
|
|
"--global",
|
|
"--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",
|
|
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",
|
|
"core.sshCommand",
|
|
"ssh -i " + sshKey,
|
|
}
|
|
|
|
return execabs.Command(
|
|
gitBin,
|
|
args...,
|
|
)
|
|
}
|