aboutsummaryrefslogtreecommitdiffstats
path: root/repository/git_config.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-09-27 00:54:14 +0200
committerMichael Muré <batolettre@gmail.com>2020-09-29 20:42:21 +0200
commit71b7eb14010be0c7799b4d5394798c89e379891b (patch)
treef82d4b7bc6be5165c093d4feb18f5ee642c2c3e6 /repository/git_config.go
parentc87e9abacfbdc4f221e2e328d4b229d6191f42e9 (diff)
downloadgit-bug-71b7eb14010be0c7799b4d5394798c89e379891b.tar.gz
repo: implement local/global/any config everywhere
Diffstat (limited to 'repository/git_config.go')
-rw-r--r--repository/git_config.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/repository/git_config.go b/repository/git_config.go
index 987cf195..b46cc69b 100644
--- a/repository/git_config.go
+++ b/repository/git_config.go
@@ -14,24 +14,24 @@ import (
var _ Config = &gitConfig{}
type gitConfig struct {
- repo *GitRepo
+ cli gitCli
localityFlag string
}
-func newGitConfig(repo *GitRepo, global bool) *gitConfig {
+func newGitConfig(cli gitCli, global bool) *gitConfig {
localityFlag := "--local"
if global {
localityFlag = "--global"
}
return &gitConfig{
- repo: repo,
+ cli: cli,
localityFlag: localityFlag,
}
}
// StoreString store a single key/value pair in the config of the repo
func (gc *gitConfig) StoreString(key string, value string) error {
- _, err := gc.repo.runGitCommand("config", gc.localityFlag, "--replace-all", key, value)
+ _, err := gc.cli.runGitCommand("config", gc.localityFlag, "--replace-all", key, value)
return err
}
@@ -45,7 +45,7 @@ func (gc *gitConfig) StoreTimestamp(key string, value time.Time) error {
// ReadAll read all key/value pair matching the key prefix
func (gc *gitConfig) ReadAll(keyPrefix string) (map[string]string, error) {
- stdout, err := gc.repo.runGitCommand("config", gc.localityFlag, "--includes", "--get-regexp", keyPrefix)
+ stdout, err := gc.cli.runGitCommand("config", gc.localityFlag, "--includes", "--get-regexp", keyPrefix)
// / \
// / ! \
@@ -74,7 +74,7 @@ func (gc *gitConfig) ReadAll(keyPrefix string) (map[string]string, error) {
}
func (gc *gitConfig) ReadString(key string) (string, error) {
- stdout, err := gc.repo.runGitCommand("config", gc.localityFlag, "--includes", "--get-all", key)
+ stdout, err := gc.cli.runGitCommand("config", gc.localityFlag, "--includes", "--get-all", key)
// / \
// / ! \
@@ -116,12 +116,12 @@ func (gc *gitConfig) ReadTimestamp(key string) (time.Time, error) {
}
func (gc *gitConfig) rmSection(keyPrefix string) error {
- _, err := gc.repo.runGitCommand("config", gc.localityFlag, "--remove-section", keyPrefix)
+ _, err := gc.cli.runGitCommand("config", gc.localityFlag, "--remove-section", keyPrefix)
return err
}
func (gc *gitConfig) unsetAll(keyPrefix string) error {
- _, err := gc.repo.runGitCommand("config", gc.localityFlag, "--unset-all", keyPrefix)
+ _, err := gc.cli.runGitCommand("config", gc.localityFlag, "--unset-all", keyPrefix)
return err
}
@@ -180,7 +180,7 @@ func (gc *gitConfig) RemoveAll(keyPrefix string) error {
}
func (gc *gitConfig) gitVersion() (*semver.Version, error) {
- versionOut, err := gc.repo.runGitCommand("version")
+ versionOut, err := gc.cli.runGitCommand("version")
if err != nil {
return nil, err
}