summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorFarzad Majidfayyaz <farzadmf@users.noreply.github.com>2020-11-10 14:57:50 -0500
committerJesse Duffield <jessedduffield@gmail.com>2020-11-19 09:43:51 +1100
commit79888d3bdeae57bad17db4b0716a5f59e7c2df31 (patch)
treec09b9598e7e36d56e82bb55fa49e7f8612dbf9bf /pkg/gui
parent4e1d3e45a3bfb3b7df5badb551df45c39b9d5c9f (diff)
Add mapping to copy a pull request URL to the clipboard
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/branches_panel.go13
-rw-r--r--pkg/gui/keybindings.go7
2 files changed, 20 insertions, 0 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 29b70928b..aadb12af4 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -99,6 +99,19 @@ func (gui *Gui) handleCreatePullRequestPress(g *gocui.Gui, v *gocui.View) error
return nil
}
+func (gui *Gui) handleCopyPullRequestURLPress(g *gocui.Gui, v *gocui.View) error {
+ pullRequest := commands.NewPullRequest(gui.GitCommand)
+
+ branch := gui.getSelectedBranch()
+ if err := pullRequest.CopyURL(branch); err != nil {
+ return gui.surfaceError(err)
+ }
+
+ return gui.createPopupPanel(createPopupPanelOpts{
+ prompt: "Pull request URL copied to clipboard",
+ })
+}
+
func (gui *Gui) handleGitFetch(g *gocui.Gui, v *gocui.View) error {
if err := gui.createLoaderPanel(gui.Tr.FetchWait); err != nil {
return err
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 2f005a442..db01c1455 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -508,6 +508,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
{
ViewName: "branches",
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
+ Key: gui.getKey(config.Branches.CopyPullRequestURL),
+ Handler: gui.handleCopyPullRequestURLPress,
+ Description: gui.Tr.LcCopyPullRequestURL,
+ },
+ {
+ ViewName: "branches",
+ Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey(config.Branches.CheckoutBranchByName),
Handler: gui.handleCheckoutByName,
Description: gui.Tr.LcCheckoutByName,