diff options
author | amine <hilalyamine@gmail.com> | 2019-10-31 19:05:50 +0100 |
---|---|---|
committer | amine <hilalyamine@gmail.com> | 2019-10-31 19:05:50 +0100 |
commit | 7f177c4750b4acf70cc3fd3d43c19685179e527b (patch) | |
tree | b3a896099d508c679f736ecf32dc70039149fe11 /repository/config_runtime.go | |
parent | ab935674a26f2eef5d8014c615b9b5bc1f402135 (diff) | |
download | git-bug-7f177c4750b4acf70cc3fd3d43c19685179e527b.tar.gz git-bug-7f177c4750b4acf70cc3fd3d43c19685179e527b.zip |
repository: add ReadTimestamp methods and improve naming
Diffstat (limited to 'repository/config_runtime.go')
-rw-r--r-- | repository/config_runtime.go | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/repository/config_runtime.go b/repository/config_runtime.go deleted file mode 100644 index 8a17edb46..000000000 --- a/repository/config_runtime.go +++ /dev/null @@ -1,59 +0,0 @@ -package repository - -import ( - "strconv" - "strings" -) - -type runtimeConfig struct { - config map[string]string -} - -func newRuntimeConfig(config map[string]string) *runtimeConfig { - return &runtimeConfig{config: config} -} - -func (rtc *runtimeConfig) Store(key, value string) error { - rtc.config[key] = value - return nil -} - -func (rtc *runtimeConfig) ReadAll(keyPrefix string) (map[string]string, error) { - result := make(map[string]string) - for key, val := range rtc.config { - if strings.HasPrefix(key, keyPrefix) { - result[key] = val - } - } - return result, nil -} - -func (rtc *runtimeConfig) ReadString(key string) (string, error) { - // unlike git, the mock can only store one value for the same key - val, ok := rtc.config[key] - if !ok { - return "", ErrNoConfigEntry - } - - return val, nil -} - -func (rtc *runtimeConfig) ReadBool(key string) (bool, error) { - // unlike git, the mock can only store one value for the same key - val, ok := rtc.config[key] - if !ok { - return false, ErrNoConfigEntry - } - - return strconv.ParseBool(val) -} - -// RmConfigs remove all key/value pair matching the key prefix -func (rtc *runtimeConfig) RemoveAll(keyPrefix string) error { - for key := range rtc.config { - if strings.HasPrefix(key, keyPrefix) { - delete(rtc.config, key) - } - } - return nil -} |