aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/core
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-10-01 21:47:12 +0200
committerMichael Muré <batolettre@gmail.com>2018-10-01 21:47:12 +0200
commita4b218adec59d5c7de564dfeef4729c4615906d6 (patch)
tree7113098f56fbd03ea77d38ea1eba1ef4ae125a63 /bridge/core
parent97d94948536b119b4825d30c546248f91c41988d (diff)
downloadgit-bug-a4b218adec59d5c7de564dfeef4729c4615906d6.tar.gz
add documentation
Diffstat (limited to 'bridge/core')
-rw-r--r--bridge/core/bridge.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go
index dd1f1337..69e9e522 100644
--- a/bridge/core/bridge.go
+++ b/bridge/core/bridge.go
@@ -1,3 +1,4 @@
+// Package core contains the target-agnostic code to define and run a bridge
package core
import (
@@ -44,6 +45,7 @@ func Targets() []string {
return result
}
+// Instantiate a new Bridge for a repo, from the given target and name
func NewBridge(repo *cache.RepoCache, target string, name string) (*Bridge, error) {
implType, ok := bridgeImpl[target]
if !ok {
@@ -61,6 +63,8 @@ func NewBridge(repo *cache.RepoCache, target string, name string) (*Bridge, erro
return bridge, nil
}
+// Instantiate a new bridge for a repo, from the combined target and name contained
+// in the full name
func NewBridgeFullName(repo *cache.RepoCache, fullName string) (*Bridge, error) {
target, name, err := splitFullName(fullName)
if err != nil {
@@ -70,6 +74,8 @@ func NewBridgeFullName(repo *cache.RepoCache, fullName string) (*Bridge, error)
return NewBridge(repo, target, name)
}
+// Attempt to retrieve a default bridge for the given repo. If zero or multiple
+// bridge exist, it fails.
func DefaultBridge(repo *cache.RepoCache) (*Bridge, error) {
bridges, err := ConfiguredBridges(repo)
if err != nil {
@@ -102,6 +108,8 @@ func splitFullName(fullName string) (string, string, error) {
return split[0], split[1], nil
}
+// ConfiguredBridges return the list of bridge that are configured for the given
+// repo
func ConfiguredBridges(repo repository.RepoCommon) ([]string, error) {
configs, err := repo.ReadConfigs("git-bug.bridge.")
if err != nil {
@@ -136,6 +144,7 @@ func ConfiguredBridges(repo repository.RepoCommon) ([]string, error) {
return result, nil
}
+// Remove a configured bridge
func RemoveBridge(repo repository.RepoCommon, fullName string) error {
re, err := regexp.Compile(`^[^\.]+\.[^\.]+$`)
if err != nil {
@@ -150,6 +159,7 @@ func RemoveBridge(repo repository.RepoCommon, fullName string) error {
return repo.RmConfigs(keyPrefix)
}
+// Configure run the target specific configuration process
func (b *Bridge) Configure() error {
conf, err := b.impl.Configure(b.repo)
if err != nil {