summaryrefslogtreecommitdiffstats
path: root/pkg/commands/os.go
diff options
context:
space:
mode:
authorKristijan Husak <husakkristijan@gmail.com>2018-10-17 14:20:15 +0200
committerKristijan Husak <husakkristijan@gmail.com>2018-10-20 11:58:08 +0200
commit990dc8c4ea1133a58d5c863abd543ee5cde1e700 (patch)
tree80cee673655645b82f7d76d2cc2be409c16c1c8e /pkg/commands/os.go
parentc69fce2e9d28dc847ad5a4528b99682fe61762af (diff)
Add separate open command for links and check if branch exists on remote before opening pull request link.
Diffstat (limited to 'pkg/commands/os.go')
-rw-r--r--pkg/commands/os.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/pkg/commands/os.go b/pkg/commands/os.go
index c8ca40f29..2caedf07d 100644
--- a/pkg/commands/os.go
+++ b/pkg/commands/os.go
@@ -8,9 +8,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/utils"
-
"github.com/mgutz/str"
-
"github.com/sirupsen/logrus"
gitconfig "github.com/tcnksm/go-gitconfig"
)
@@ -22,6 +20,7 @@ type Platform struct {
shellArg string
escapedQuote string
openCommand string
+ openLinkCommand string
fallbackEscapedQuote string
}
@@ -110,6 +109,18 @@ func (c *OSCommand) OpenFile(filename string) error {
return err
}
+// OpenFile opens a file with the given
+func (c *OSCommand) OpenLink(link string) error {
+ commandTemplate := c.Config.GetUserConfig().GetString("os.openLinkCommand")
+ templateValues := map[string]string{
+ "link": c.Quote(link),
+ }
+
+ command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
+ err := c.RunCommand(command)
+ return err
+}
+
// EditFile opens a file in a subprocess using whatever editor is available,
// falling back to core.editor, VISUAL, EDITOR, then vi
func (c *OSCommand) EditFile(filename string) (*exec.Cmd, error) {