aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bridge/bridges.go8
-rw-r--r--bridge/core/bridge.go41
-rw-r--r--commands/bridge_pull.go45
-rw-r--r--doc/man/git-bug-bridge-pull.129
-rw-r--r--doc/man/git-bug-bridge.12
-rw-r--r--doc/md/git-bug_bridge.md1
-rw-r--r--doc/md/git-bug_bridge_pull.md22
-rw-r--r--misc/bash_completion/git-bug21
-rw-r--r--misc/zsh_completion/git-bug12
9 files changed, 174 insertions, 7 deletions
diff --git a/bridge/bridges.go b/bridge/bridges.go
index 2fcb13d3..bfd851aa 100644
--- a/bridge/bridges.go
+++ b/bridge/bridges.go
@@ -16,6 +16,14 @@ func NewBridge(repo *cache.RepoCache, target string, name string) (*core.Bridge,
return core.NewBridge(repo, target, name)
}
+func NewBridgeFullName(repo *cache.RepoCache, fullName string) (*core.Bridge, error) {
+ return core.NewBridgeFullName(repo, fullName)
+}
+
+func DefaultBridge(repo *cache.RepoCache) (*core.Bridge, error) {
+ return core.DefaultBridge(repo)
+}
+
func ConfiguredBridges(repo repository.RepoCommon) ([]string, error) {
return core.ConfiguredBridges(repo)
}
diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go
index 0eb24c6d..d9d688ba 100644
--- a/bridge/core/bridge.go
+++ b/bridge/core/bridge.go
@@ -61,6 +61,47 @@ func NewBridge(repo *cache.RepoCache, target string, name string) (*Bridge, erro
return bridge, nil
}
+func NewBridgeFullName(repo *cache.RepoCache, fullName string) (*Bridge, error) {
+ target, name, err := splitFullName(fullName)
+ if err != nil {
+ return nil, err
+ }
+
+ return NewBridge(repo, target, name)
+}
+
+func DefaultBridge(repo *cache.RepoCache) (*Bridge, error) {
+ bridges, err := ConfiguredBridges(repo)
+ if err != nil {
+ return nil, err
+ }
+
+ if len(bridges) == 0 {
+ return nil, fmt.Errorf("no configured bridge")
+ }
+
+ if len(bridges) > 1 {
+ return nil, fmt.Errorf("multiple bridge configured")
+ }
+
+ target, name, err := splitFullName(bridges[0])
+ if err != nil {
+ return nil, err
+ }
+
+ return NewBridge(repo, target, name)
+}
+
+func splitFullName(fullName string) (string, string, error) {
+ split := strings.Split(fullName, ".")
+
+ if len(split) != 2 {
+ return "", "", fmt.Errorf("bad bridge fullname: %s", fullName)
+ }
+
+ return split[0], split[1], nil
+}
+
func ConfiguredBridges(repo repository.RepoCommon) ([]string, error) {
configs, err := repo.ReadConfigs("git-bug.bridge.")
if err != nil {
diff --git a/commands/bridge_pull.go b/commands/bridge_pull.go
new file mode 100644
index 00000000..fc12d369
--- /dev/null
+++ b/commands/bridge_pull.go
@@ -0,0 +1,45 @@
+package commands
+
+import (
+ "github.com/MichaelMure/git-bug/bridge"
+ "github.com/MichaelMure/git-bug/bridge/core"
+ "github.com/MichaelMure/git-bug/cache"
+ "github.com/spf13/cobra"
+)
+
+func runBridgePull(cmd *cobra.Command, args []string) error {
+ backend, err := cache.NewRepoCache(repo)
+ if err != nil {
+ return err
+ }
+ defer backend.Close()
+
+ var b *core.Bridge
+
+ if len(args) == 0 {
+ b, err = bridge.DefaultBridge(backend)
+ } else {
+ b, err = bridge.NewBridgeFullName(backend, args[0])
+ }
+
+ if err != nil {
+ return err
+ }
+
+ err = b.ImportAll()
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+var bridgePullCmd = &cobra.Command{
+ Use: "pull [<name>]",
+ Short: "Pull updates",
+ RunE: runBridgePull,
+}
+
+func init() {
+ bridgeCmd.AddCommand(bridgePullCmd)
+}
diff --git a/doc/man/git-bug-bridge-pull.1 b/doc/man/git-bug-bridge-pull.1
new file mode 100644
index 00000000..cc00b913
--- /dev/null
+++ b/doc/man/git-bug-bridge-pull.1
@@ -0,0 +1,29 @@
+.TH "GIT-BUG" "1" "Sep 2018" "Generated from git-bug's source code" ""
+.nh
+.ad l
+
+
+.SH NAME
+.PP
+git\-bug\-bridge\-pull \- Pull updates
+
+
+.SH SYNOPSIS
+.PP
+\fBgit\-bug bridge pull [<name>] [flags]\fP
+
+
+.SH DESCRIPTION
+.PP
+Pull updates
+
+
+.SH OPTIONS
+.PP
+\fB\-h\fP, \fB\-\-help\fP[=false]
+ help for pull
+
+
+.SH SEE ALSO
+.PP
+\fBgit\-bug\-bridge(1)\fP
diff --git a/doc/man/git-bug-bridge.1 b/doc/man/git-bug-bridge.1
index 3e7b39fd..473df2ae 100644
--- a/doc/man/git-bug-bridge.1
+++ b/doc/man/git-bug-bridge.1
@@ -26,4 +26,4 @@ Configure and use bridges to other bug trackers
.SH SEE ALSO
.PP
-\fBgit\-bug(1)\fP, \fBgit\-bug\-bridge\-configure(1)\fP, \fBgit\-bug\-bridge\-rm(1)\fP
+\fBgit\-bug(1)\fP, \fBgit\-bug\-bridge\-configure(1)\fP, \fBgit\-bug\-bridge\-pull(1)\fP, \fBgit\-bug\-bridge\-rm(1)\fP
diff --git a/doc/md/git-bug_bridge.md b/doc/md/git-bug_bridge.md
index 7dd6c73d..da7f0978 100644
--- a/doc/md/git-bug_bridge.md
+++ b/doc/md/git-bug_bridge.md
@@ -20,5 +20,6 @@ git-bug bridge [flags]
* [git-bug](git-bug.md) - A bug tracker embedded in Git
* [git-bug bridge configure](git-bug_bridge_configure.md) - Configure a new bridge
+* [git-bug bridge pull](git-bug_bridge_pull.md) - Pull updates
* [git-bug bridge rm](git-bug_bridge_rm.md) - Delete a configured bridge
diff --git a/doc/md/git-bug_bridge_pull.md b/doc/md/git-bug_bridge_pull.md
new file mode 100644
index 00000000..10da2e8a
--- /dev/null
+++ b/doc/md/git-bug_bridge_pull.md
@@ -0,0 +1,22 @@
+## git-bug bridge pull
+
+Pull updates
+
+### Synopsis
+
+Pull updates
+
+```
+git-bug bridge pull [<name>] [flags]
+```
+
+### Options
+
+```
+ -h, --help help for pull
+```
+
+### SEE ALSO
+
+* [git-bug bridge](git-bug_bridge.md) - Configure and use bridges to other bug trackers
+
diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug
index 0f9d3f01..496c900b 100644
--- a/misc/bash_completion/git-bug
+++ b/misc/bash_completion/git-bug
@@ -297,6 +297,26 @@ _git-bug_bridge_configure()
noun_aliases=()
}
+_git-bug_bridge_pull()
+{
+ last_command="git-bug_bridge_pull"
+
+ command_aliases=()
+
+ commands=()
+
+ flags=()
+ two_word_flags=()
+ local_nonpersistent_flags=()
+ flags_with_completion=()
+ flags_completion=()
+
+
+ must_have_one_flag=()
+ must_have_one_noun=()
+ noun_aliases=()
+}
+
_git-bug_bridge_rm()
{
last_command="git-bug_bridge_rm"
@@ -325,6 +345,7 @@ _git-bug_bridge()
commands=()
commands+=("configure")
+ commands+=("pull")
commands+=("rm")
flags=()
diff --git a/misc/zsh_completion/git-bug b/misc/zsh_completion/git-bug
index 15b572be..8d2d9208 100644
--- a/misc/zsh_completion/git-bug
+++ b/misc/zsh_completion/git-bug
@@ -17,12 +17,6 @@ case $state in
;;
level2)
case $words[2] in
- title)
- _arguments '2: :(edit)'
- ;;
- bridge)
- _arguments '2: :(configure rm)'
- ;;
comment)
_arguments '2: :(add)'
;;
@@ -32,6 +26,12 @@ case $state in
status)
_arguments '2: :(close open)'
;;
+ title)
+ _arguments '2: :(edit)'
+ ;;
+ bridge)
+ _arguments '2: :(configure pull rm)'
+ ;;
*)
_arguments '*: :_files'
;;