mirror of
https://github.com/grdl/git-get.git
synced 2026-02-04 16:14:48 +00:00
Add a run package responsible for running git commands
- Add better git error handling - Move repo helpers into a separate package
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
package git
|
||||
|
||||
import "os/exec"
|
||||
import (
|
||||
"git-get/pkg/run"
|
||||
)
|
||||
|
||||
// ConfigGlobal represents a global gitconfig file.
|
||||
type ConfigGlobal struct{}
|
||||
|
||||
// Get reads a value from global gitconfig file. Returns empty string when key is missing.
|
||||
func (c *ConfigGlobal) Get(key string) string {
|
||||
cmd := exec.Command("git", "config", "--global", key)
|
||||
out, err := cmd.Output()
|
||||
|
||||
out, err := run.Git("config", "--global").AndCaptureLine()
|
||||
// In case of error return an empty string, the missing value will fall back to a default.
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
lines := lines(out)
|
||||
return lines[0]
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user