6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-04 20:19:42 +00:00
Files
git-get/pkg/git/config.go
Grzegorz Dlugoszewski 28b24ec5ce Add a run package responsible for running git commands
- Add better git error handling
- Move repo helpers into a separate package
2020-06-26 13:36:58 +02:00

20 lines
462 B
Go

package git
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 {
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 ""
}
return out
}