aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/core/bridge.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-07-07 12:15:01 +0200
committerMichael Muré <batolettre@gmail.com>2019-07-07 12:15:01 +0200
commitdc289876c625ec1c606e84112a6b6c53310e19be (patch)
tree0455ee404252f1b682980ffa0e6df6200bef06da /bridge/core/bridge.go
parent5b1a8cdefa9516d215f99ee114d451c96997f34a (diff)
downloadgit-bug-dc289876c625ec1c606e84112a6b6c53310e19be.tar.gz
bridge: detect when trying to configure a bridge with a name already taken
Diffstat (limited to 'bridge/core/bridge.go')
-rw-r--r--bridge/core/bridge.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go
index a8a0c033..abb57ed7 100644
--- a/bridge/core/bridge.go
+++ b/bridge/core/bridge.go
@@ -163,6 +163,15 @@ func ConfiguredBridges(repo repository.RepoCommon) ([]string, error) {
return result, nil
}
+// Check if a bridge exist
+func BridgeExist(repo repository.RepoCommon, name string) bool {
+ keyPrefix := fmt.Sprintf("git-bug.bridge.%s.", name)
+
+ conf, err := repo.ReadConfigs(keyPrefix)
+
+ return err == nil && len(conf) > 0
+}
+
// Remove a configured bridge
func RemoveBridge(repo repository.RepoCommon, name string) error {
re, err := regexp.Compile(`^[a-zA-Z0-9]+`)
@@ -219,7 +228,7 @@ func (b *Bridge) ensureConfig() error {
return nil
}
-func loadConfig(repo *cache.RepoCache, name string) (Configuration, error) {
+func loadConfig(repo repository.RepoCommon, name string) (Configuration, error) {
keyPrefix := fmt.Sprintf("git-bug.bridge.%s.", name)
pairs, err := repo.ReadConfigs(keyPrefix)