From 60c6bd360f164b8f955b21cd1d0bc0cca6e5cb51 Mon Sep 17 00:00:00 2001 From: amine Date: Fri, 1 Nov 2019 22:40:21 +0100 Subject: bridge: use new repository configuration interface commands/webui: use new repository configuration interface --- repository/mock_repo.go | 51 ++----------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) (limited to 'repository/mock_repo.go') 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 -- cgit