0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-10-31 09:40:40 +00:00
wp-git-action/git/config.go

89 lines
1.8 KiB
Go
Raw Permalink Normal View History

2022-11-27 13:33:39 +00:00
package git
2019-06-07 10:32:16 +00:00
import (
"strconv"
plugin_exec "github.com/thegeeklab/wp-plugin-go/v3/exec"
2019-06-07 10:32:16 +00:00
)
// ConfigAutocorrect sets the local git autocorrect configuration for the given repository.
// The autocorrect setting determines how git handles minor typos in commands.
func (r *Repository) ConfigAutocorrect() *plugin_exec.Cmd {
args := []string{
"config",
"--local",
"help.autocorrect",
2024-05-06 18:29:57 +00:00
r.Autocorrect,
}
cmd := plugin_exec.Command(gitBin, args...)
2024-05-06 18:29:57 +00:00
cmd.Dir = r.WorkDir
cmd.Trace = false
2024-05-06 20:43:56 +00:00
return cmd
}
// ConfigUserEmail sets the global git author email.
func (r *Repository) ConfigUserEmail() *plugin_exec.Cmd {
args := []string{
2019-06-07 10:32:16 +00:00
"config",
"--local",
2019-06-07 10:32:16 +00:00
"user.email",
2024-05-06 18:29:57 +00:00
r.Author.Email,
}
cmd := plugin_exec.Command(gitBin, args...)
2024-05-06 18:29:57 +00:00
cmd.Dir = r.WorkDir
cmd.Trace = false
2019-06-07 10:32:16 +00:00
2024-05-06 20:43:56 +00:00
return cmd
2019-06-07 10:32:16 +00:00
}
// ConfigUserName configures the user.name git config setting for the given repository.
func (r *Repository) ConfigUserName() *plugin_exec.Cmd {
args := []string{
2019-06-07 10:32:16 +00:00
"config",
"--local",
2019-06-07 10:32:16 +00:00
"user.name",
2024-05-06 18:29:57 +00:00
r.Author.Name,
}
cmd := plugin_exec.Command(gitBin, args...)
2024-05-06 18:29:57 +00:00
cmd.Dir = r.WorkDir
cmd.Trace = false
2019-06-07 10:32:16 +00:00
2024-05-06 20:43:56 +00:00
return cmd
2019-06-07 10:32:16 +00:00
}
// ConfigSSLVerify configures the http.sslVerify git config setting for the given repository.
func (r *Repository) ConfigSSLVerify(skipVerify bool) *plugin_exec.Cmd {
args := []string{
"config",
"--local",
"http.sslVerify",
strconv.FormatBool(!skipVerify),
}
cmd := plugin_exec.Command(gitBin, args...)
2024-05-06 18:29:57 +00:00
cmd.Dir = r.WorkDir
cmd.Trace = false
2024-05-06 20:43:56 +00:00
return cmd
}
// ConfigSSHCommand sets custom SSH key.
func (r *Repository) ConfigSSHCommand(sshKey string) *plugin_exec.Cmd {
args := []string{
"config",
"--local",
"core.sshCommand",
"ssh -i " + sshKey,
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Dir = r.WorkDir
cmd.Trace = false
2024-05-06 20:43:56 +00:00
return cmd
}