2022-11-27 13:33:39 +00:00
|
|
|
package git
|
2019-06-07 10:32:16 +00:00
|
|
|
|
|
|
|
import (
|
2022-12-02 21:21:35 +00:00
|
|
|
"os"
|
2022-11-29 09:40:42 +00:00
|
|
|
"strconv"
|
2023-02-08 09:16:10 +00:00
|
|
|
|
|
|
|
"golang.org/x/sys/execabs"
|
2019-06-07 10:32:16 +00:00
|
|
|
)
|
|
|
|
|
2022-12-02 21:21:35 +00:00
|
|
|
// repoUserEmail sets the global git author email.
|
2023-02-08 09:16:10 +00:00
|
|
|
func ConfigAutocorrect(repo Repository) *execabs.Cmd {
|
|
|
|
args := []string{
|
2022-12-02 21:21:35 +00:00
|
|
|
"config",
|
|
|
|
"--local",
|
|
|
|
"help.autocorrect",
|
|
|
|
repo.Autocorrect,
|
2023-02-08 09:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd := execabs.Command(
|
|
|
|
gitBin,
|
|
|
|
args...,
|
2022-12-02 21:21:35 +00:00
|
|
|
)
|
|
|
|
cmd.Dir = repo.WorkDir
|
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
// repoUserEmail sets the global git author email.
|
2023-02-08 09:16:10 +00:00
|
|
|
func ConfigUserEmail(repo Repository) *execabs.Cmd {
|
|
|
|
args := []string{
|
2019-06-07 10:32:16 +00:00
|
|
|
"config",
|
2022-11-29 09:40:42 +00:00
|
|
|
"--local",
|
2019-06-07 10:32:16 +00:00
|
|
|
"user.email",
|
2022-12-02 21:21:35 +00:00
|
|
|
repo.Author.Email,
|
2023-02-08 09:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd := execabs.Command(
|
|
|
|
gitBin,
|
|
|
|
args...,
|
2022-12-02 21:21:35 +00:00
|
|
|
)
|
|
|
|
cmd.Dir = repo.WorkDir
|
|
|
|
cmd.Stderr = os.Stderr
|
2019-06-07 10:32:16 +00:00
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2022-12-02 21:21:35 +00:00
|
|
|
// repoUserName sets the global git author name.
|
2023-02-08 09:16:10 +00:00
|
|
|
func ConfigUserName(repo Repository) *execabs.Cmd {
|
|
|
|
args := []string{
|
2019-06-07 10:32:16 +00:00
|
|
|
"config",
|
2022-11-29 09:40:42 +00:00
|
|
|
"--local",
|
2019-06-07 10:32:16 +00:00
|
|
|
"user.name",
|
2022-12-02 21:21:35 +00:00
|
|
|
repo.Author.Name,
|
2023-02-08 09:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd := execabs.Command(
|
|
|
|
gitBin,
|
|
|
|
args...,
|
2022-12-02 21:21:35 +00:00
|
|
|
)
|
|
|
|
cmd.Dir = repo.WorkDir
|
|
|
|
cmd.Stderr = os.Stderr
|
2019-06-07 10:32:16 +00:00
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
2022-11-29 09:40:42 +00:00
|
|
|
|
2022-12-02 21:21:35 +00:00
|
|
|
// repoSSLVerify disables globally the git ssl verification.
|
2023-02-08 09:16:10 +00:00
|
|
|
func ConfigSSLVerify(repo Repository) *execabs.Cmd {
|
|
|
|
args := []string{
|
2022-11-29 09:40:42 +00:00
|
|
|
"config",
|
|
|
|
"--local",
|
|
|
|
"http.sslVerify",
|
2022-12-02 21:21:35 +00:00
|
|
|
strconv.FormatBool(repo.SSLVerify),
|
2023-02-08 09:16:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd := execabs.Command(
|
|
|
|
gitBin,
|
|
|
|
args...,
|
2022-12-02 21:21:35 +00:00
|
|
|
)
|
|
|
|
cmd.Dir = repo.WorkDir
|
|
|
|
cmd.Stderr = os.Stderr
|
2022-11-29 09:40:42 +00:00
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|