0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-11-28 18:20:35 +00:00
wp-git-action/git/config.go

68 lines
1.1 KiB
Go
Raw Normal View History

2022-11-27 13:33:39 +00:00
package git
2019-06-07 10:32:16 +00:00
import (
"os"
2019-06-07 10:32:16 +00:00
"os/exec"
"strconv"
2019-06-07 10:32:16 +00:00
)
// repoUserEmail sets the global git author email.
func ConfigAutocorrect(repo Repository) *exec.Cmd {
cmd := exec.Command(
"git",
"config",
"--local",
"help.autocorrect",
repo.Autocorrect,
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}
// repoUserEmail sets the global git author email.
func ConfigUserEmail(repo Repository) *exec.Cmd {
2019-06-07 10:32:16 +00:00
cmd := exec.Command(
"git",
"config",
"--local",
2019-06-07 10:32:16 +00:00
"user.email",
repo.Author.Email,
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
2019-06-07 10:32:16 +00:00
return cmd
}
// repoUserName sets the global git author name.
func ConfigUserName(repo Repository) *exec.Cmd {
2019-06-07 10:32:16 +00:00
cmd := exec.Command(
"git",
"config",
"--local",
2019-06-07 10:32:16 +00:00
"user.name",
repo.Author.Name,
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
2019-06-07 10:32:16 +00:00
return cmd
}
// repoSSLVerify disables globally the git ssl verification.
func ConfigSSLVerify(repo Repository) *exec.Cmd {
cmd := exec.Command(
"git",
"config",
"--local",
"http.sslVerify",
strconv.FormatBool(repo.SSLVerify),
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}