diff options
author | amine <hilalyamine@gmail.com> | 2019-11-01 22:40:21 +0100 |
---|---|---|
committer | amine <hilalyamine@gmail.com> | 2019-11-01 22:44:11 +0100 |
commit | 60c6bd360f164b8f955b21cd1d0bc0cca6e5cb51 (patch) | |
tree | f82d8638276ddffe244063c5deffb8b7c21cbcd6 /repository/mock_repo.go | |
parent | 618f896f667b272c1272b1289c8ff3f3310c3168 (diff) | |
download | git-bug-60c6bd360f164b8f955b21cd1d0bc0cca6e5cb51.tar.gz |
bridge: use new repository configuration interface
commands/webui: use new repository configuration interface
Diffstat (limited to 'repository/mock_repo.go')
-rw-r--r-- | repository/mock_repo.go | 51 |
1 files changed, 2 insertions, 49 deletions
diff --git a/repository/mock_repo.go b/repository/mock_repo.go index bdf36ac2..26c02ede 100644 --- a/repository/mock_repo.go +++ b/repository/mock_repo.go @@ -3,8 +3,6 @@ package repository import ( "crypto/sha1" "fmt" - "strconv" - "strings" "github.com/MichaelMure/git-bug/util/git" "github.com/MichaelMure/git-bug/util/lamport" @@ -41,10 +39,12 @@ func NewMockRepoForTest() *mockRepoForTest { } } +// LocalConfig give access to the repository scoped configuration func (r *mockRepoForTest) LocalConfig() Config { return newMemConfig(r.config) } +// GlobalConfig give access to the git global configuration func (r *mockRepoForTest) GlobalConfig() Config { return newMemConfig(r.globalConfig) } @@ -75,53 +75,6 @@ func (r *mockRepoForTest) GetRemotes() (map[string]string, error) { }, nil } -func (r *mockRepoForTest) StoreConfig(key string, value string) error { - r.config[key] = value - return nil -} - -func (r *mockRepoForTest) ReadConfigs(keyPrefix string) (map[string]string, error) { - result := make(map[string]string) - - for key, val := range r.config { - if strings.HasPrefix(key, keyPrefix) { - result[key] = val - } - } - - return result, nil -} - -func (r *mockRepoForTest) ReadConfigBool(key string) (bool, error) { - // unlike git, the mock can only store one value for the same key - val, ok := r.config[key] - if !ok { - return false, ErrNoConfigEntry - } - - return strconv.ParseBool(val) -} - -func (r *mockRepoForTest) ReadConfigString(key string) (string, error) { - // unlike git, the mock can only store one value for the same key - val, ok := r.config[key] - if !ok { - return "", ErrNoConfigEntry - } - - return val, nil -} - -// RmConfigs remove all key/value pair matching the key prefix -func (r *mockRepoForTest) RmConfigs(keyPrefix string) error { - for key := range r.config { - if strings.HasPrefix(key, keyPrefix) { - delete(r.config, key) - } - } - return nil -} - // PushRefs push git refs to a remote func (r *mockRepoForTest) PushRefs(remote string, refSpec string) (string, error) { return "", nil |