0
0
mirror of https://github.com/thegeeklab/wp-git-clone.git synced 2024-11-15 05:40:40 +00:00
wp-git-clone/git/config.go

71 lines
1.4 KiB
Go
Raw Normal View History

2023-12-22 23:59:23 +00:00
package git
import (
"fmt"
"strconv"
plugin_exec "github.com/thegeeklab/wp-plugin-go/v3/exec"
2023-12-22 23:59:23 +00:00
)
// ConfigSSLVerify disables globally the git ssl verification.
func (r *Repository) ConfigSSLVerify(skipVerify bool) *plugin_exec.Cmd {
2023-12-22 23:59:23 +00:00
args := []string{
"config",
"--global",
2023-12-22 23:59:23 +00:00
"http.sslVerify",
strconv.FormatBool(!skipVerify),
2023-12-22 23:59:23 +00:00
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Trace = false
return cmd
2023-12-22 23:59:23 +00:00
}
// ConfigSafeDirectory disables globally the git ssl verification.
func (r *Repository) ConfigSafeDirectory() *plugin_exec.Cmd {
2023-12-22 23:59:23 +00:00
args := []string{
"config",
"--global",
2023-12-22 23:59:23 +00:00
"--replace-all",
"safe.directory",
r.SafeDirectory,
2023-12-22 23:59:23 +00:00
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Trace = false
return cmd
2023-12-22 23:59:23 +00:00
}
// ConfigRemapSubmodule returns a git command that, when executed configures git to
// remap submodule urls.
func (r *Repository) ConfigRemapSubmodule(name, url string) *plugin_exec.Cmd {
2023-12-22 23:59:23 +00:00
args := []string{
"config",
"--global",
2023-12-22 23:59:23 +00:00
fmt.Sprintf("submodule.%s.url", name),
url,
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Trace = false
return cmd
2023-12-22 23:59:23 +00:00
}
// ConfigSSHCommand sets custom SSH key.
func (r *Repository) ConfigSSHCommand(sshKey string) *plugin_exec.Cmd {
2023-12-22 23:59:23 +00:00
args := []string{
"config",
"--global",
2023-12-22 23:59:23 +00:00
"core.sshCommand",
"ssh -i " + sshKey,
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Trace = false
return cmd
2023-12-22 23:59:23 +00:00
}