aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/core/bridge.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-12-26 21:42:47 +0100
committerGitHub <noreply@github.com>2019-12-26 21:42:47 +0100
commit3a3a4ffacd288627f84b367e9a735c3b1451c78b (patch)
tree94ee4e247291de89abd842cd77a39dfb3919fe55 /bridge/core/bridge.go
parente96d8e6771086e20639a16abf6af30f2faa006a0 (diff)
parent864d3ed33597211f22177fce6ecb7e741db795b5 (diff)
downloadgit-bug-3a3a4ffacd288627f84b367e9a735c3b1451c78b.tar.gz
Merge pull request #278 from MichaelMure/bridge-conf-workflow
bridge: allow to configure and pull without having set a user first
Diffstat (limited to 'bridge/core/bridge.go')
-rw-r--r--bridge/core/bridge.go43
1 files changed, 30 insertions, 13 deletions
diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go
index c6731ff9..1d0a4681 100644
--- a/bridge/core/bridge.go
+++ b/bridge/core/bridge.go
@@ -43,13 +43,14 @@ type BridgeParams struct {
// Bridge is a wrapper around a BridgeImpl that will bind low-level
// implementation with utility code to provide high-level functions.
type Bridge struct {
- Name string
- repo *cache.RepoCache
- impl BridgeImpl
- importer Importer
- exporter Exporter
- conf Configuration
- initDone bool
+ Name string
+ repo *cache.RepoCache
+ impl BridgeImpl
+ importer Importer
+ exporter Exporter
+ conf Configuration
+ initImportDone bool
+ initExportDone bool
}
// Register will register a new BridgeImpl
@@ -273,8 +274,25 @@ func (b *Bridge) getExporter() Exporter {
return b.exporter
}
-func (b *Bridge) ensureInit() error {
- if b.initDone {
+func (b *Bridge) ensureImportInit() error {
+ if b.initImportDone {
+ return nil
+ }
+
+ importer := b.getImporter()
+ if importer != nil {
+ err := importer.Init(b.repo, b.conf)
+ if err != nil {
+ return err
+ }
+ }
+
+ b.initImportDone = true
+ return nil
+}
+
+func (b *Bridge) ensureExportInit() error {
+ if b.initExportDone {
return nil
}
@@ -294,8 +312,7 @@ func (b *Bridge) ensureInit() error {
}
}
- b.initDone = true
-
+ b.initExportDone = true
return nil
}
@@ -313,7 +330,7 @@ func (b *Bridge) ImportAllSince(ctx context.Context, since time.Time) (<-chan Im
return nil, err
}
- err = b.ensureInit()
+ err = b.ensureImportInit()
if err != nil {
return nil, err
}
@@ -367,7 +384,7 @@ func (b *Bridge) ExportAll(ctx context.Context, since time.Time) (<-chan ExportR
return nil, err
}
- err = b.ensureInit()
+ err = b.ensureExportInit()
if err != nil {
return nil, err
}