summaryrefslogtreecommitdiffstats
path: root/pkg/gui/branches_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-12-28 13:58:09 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-12-29 09:01:06 +1100
commit9ef65574db3f0fd30b3782a8582212619edf4650 (patch)
tree70a85c69018d6bec09d42095245fde3428e7fb01 /pkg/gui/branches_panel.go
parentf89747451a609484bea0b2b5a004a6c3da66aaeb (diff)
refactor to rename pull_request to hosting_service and apply SRP
Diffstat (limited to 'pkg/gui/branches_panel.go')
-rw-r--r--pkg/gui/branches_panel.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 487084e97..dee321979 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -1,6 +1,7 @@
package gui
import (
+ "errors"
"fmt"
"strings"
@@ -104,13 +105,24 @@ func (gui *Gui) handleCreatePullRequestMenu() error {
}
func (gui *Gui) handleCopyPullRequestURLPress() error {
- pullRequest := commands.NewPullRequest(gui.GitCommand)
+ hostingServiceMgr := gui.getHostingServiceMgr()
branch := gui.getSelectedBranch()
- url, err := pullRequest.CopyURL(branch.Name, "")
+
+ branchExistsOnRemote := gui.GitCommand.CheckRemoteBranchExists(branch.Name)
+
+ if !branchExistsOnRemote {
+ return gui.surfaceError(errors.New(gui.Tr.NoBranchOnRemote))
+ }
+
+ url, err := hostingServiceMgr.GetPullRequestURL(branch.Name, "")
if err != nil {
return gui.surfaceError(err)
}
+ if err := gui.GitCommand.OSCommand.CopyToClipboard(url); err != nil {
+ return gui.surfaceError(err)
+ }
+
gui.OnRunCommand(oscommands.NewCmdLogEntry(fmt.Sprintf("Copying to clipboard: '%s'", url), "Copy URL", false))
gui.raiseToast(gui.Tr.PullRequestURLCopiedToClipboard)