0
0
mirror of https://github.com/thegeeklab/wp-git-clone.git synced 2024-11-22 10:20:38 +00:00
wp-git-clone/git/config.go

71 lines
1.3 KiB
Go

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