aboutsummaryrefslogtreecommitdiffstats
path: root/storage/transactional/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'storage/transactional/config.go')
-rw-r--r--storage/transactional/config.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/storage/transactional/config.go b/storage/transactional/config.go
new file mode 100644
index 0000000..2fc6583
--- /dev/null
+++ b/storage/transactional/config.go
@@ -0,0 +1,36 @@
+package transactional
+
+import "gopkg.in/src-d/go-git.v4/config"
+
+type ConfigStorage struct {
+ config.ConfigStorer
+ temporal config.ConfigStorer
+
+ set bool
+}
+
+func NewConfigStorage(s, temporal config.ConfigStorer) *ConfigStorage {
+ return &ConfigStorage{ConfigStorer: s, temporal: temporal}
+}
+
+func (c *ConfigStorage) SetConfig(cfg *config.Config) error {
+ if err := c.temporal.SetConfig(cfg); err != nil {
+ return err
+ }
+
+ c.set = true
+ return nil
+}
+
+func (c *ConfigStorage) Commit() error {
+ if !c.set {
+ return nil
+ }
+
+ cfg, err := c.temporal.Config()
+ if err != nil {
+ return err
+ }
+
+ return c.ConfigStorer.SetConfig(cfg)
+}