0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-11-10 03:20:40 +00:00
wp-git-action/git/config.go
Robert Kaussow 6709777a8c
fix: fix wrong handling of insecure-skip-ssl-verify param (#68)
BREAKING CHANGE: The parameter `insecure_ssl_verify` was renamed to `insecure_skip_ssl_verify`
2023-12-24 00:17:55 +01:00

85 lines
1.3 KiB
Go

package git
import (
"os"
"strconv"
"golang.org/x/sys/execabs"
)
// repoUserEmail sets the global git author email.
func ConfigAutocorrect(repo Repository) *execabs.Cmd {
args := []string{
"config",
"--local",
"help.autocorrect",
repo.Autocorrect,
}
cmd := execabs.Command(
gitBin,
args...,
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}
// repoUserEmail sets the global git author email.
func ConfigUserEmail(repo Repository) *execabs.Cmd {
args := []string{
"config",
"--local",
"user.email",
repo.Author.Email,
}
cmd := execabs.Command(
gitBin,
args...,
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}
// repoUserName sets the global git author name.
func ConfigUserName(repo Repository) *execabs.Cmd {
args := []string{
"config",
"--local",
"user.name",
repo.Author.Name,
}
cmd := execabs.Command(
gitBin,
args...,
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}
// ConfigSSLVerify disables globally the git ssl verification.
func ConfigSSLVerify(repo Repository) *execabs.Cmd {
args := []string{
"config",
"--local",
"http.sslVerify",
strconv.FormatBool(!repo.InsecureSkipSSLVerify),
}
cmd := execabs.Command(
gitBin,
args...,
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}