aboutsummaryrefslogtreecommitdiffstats
path: root/repository/config.go
diff options
context:
space:
mode:
authoramine <hilalyamine@gmail.com>2019-11-01 18:39:45 +0100
committeramine <hilalyamine@gmail.com>2019-11-01 18:39:45 +0100
commit104224c9f081fbe79757976a8c1f903ae94c3f8a (patch)
treeab3f954fe9ba86099c1606cf0fb074834d318834 /repository/config.go
parent7f177c4750b4acf70cc3fd3d43c19685179e527b (diff)
downloadgit-bug-104224c9f081fbe79757976a8c1f903ae94c3f8a.tar.gz
repository: add StoreTimestamp/StoreBool to the config interface
repository: move the gitVersion logic to *gitConfig struct
Diffstat (limited to 'repository/config.go')
-rw-r--r--repository/config.go25
1 files changed, 22 insertions, 3 deletions
diff --git a/repository/config.go b/repository/config.go
index 70f11081..ec5094e0 100644
--- a/repository/config.go
+++ b/repository/config.go
@@ -1,11 +1,20 @@
package repository
-import "time"
+import (
+ "strconv"
+ "time"
+)
// Config represent the common function interacting with the repository config storage
type Config interface {
- // Store writes a single key/value pair in the config of the repo
- Store(key string, value string) error
+ // Store writes a single key/value pair in the config
+ StoreString(key, value string) error
+
+ // Store writes a key and timestamp value to the config
+ StoreTimestamp(key string, value time.Time) error
+
+ // Store writes a key and boolean value to the config
+ StoreBool(key string, value bool) error
// ReadAll reads all key/value pair matching the key prefix
ReadAll(keyPrefix string) (map[string]string, error)
@@ -28,3 +37,13 @@ type Config interface {
// RemoveAll removes all key/value pair matching the key prefix
RemoveAll(keyPrefix string) error
}
+
+func parseTimestamp(s string) (*time.Time, error) {
+ timestamp, err := strconv.Atoi(s)
+ if err != nil {
+ return nil, err
+ }
+
+ t := time.Unix(int64(timestamp), 0)
+ return &t, nil
+}