mirror of
https://github.com/grdl/git-get.git
synced 2026-02-04 14:31:49 +00:00
21 lines
565 B
Go
21 lines
565 B
Go
// Package git implements functionalities to read and manipulate git repositories
|
|
package git
|
|
|
|
import (
|
|
"github.com/grdl/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", key).AndCaptureLine()
|
|
// In case of error return an empty string, the missing value will fall back to a default.
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
return out
|
|
}
|