From 6ba46ad604f7050dbdf8bc200c46ef257218c1a8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 25 Mar 2026 12:37:16 +0100 Subject: [PATCH] Change "Copy pull request URL to clipboard" command to use existing PR if there is one --- pkg/gui/controllers/branches_controller.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index eedd1542a..1c3d9e350 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -525,16 +525,23 @@ func (self *BranchesController) handleCreatePullRequestMenu(selectedBranch *mode return self.createPullRequestMenu(selectedBranch, checkedOutBranch) } -func (self *BranchesController) copyPullRequestURL() error { +func (self *BranchesController) getPullRequestURL() (string, error) { branch := self.context().GetSelected() + if pr, ok := self.c.Model().PullRequestsMap[branch.Name]; ok { + return pr.Url, nil + } branchExistsOnRemote := self.c.Git().Remote.CheckRemoteBranchExists(branch.Name) if !branchExistsOnRemote { - return errors.New(self.c.Tr.NoBranchOnRemote) + return "", errors.New(self.c.Tr.NoBranchOnRemote) } - url, err := self.c.Helpers().Host.GetPullRequestURL(branch.Name, "") + return self.c.Helpers().Host.GetPullRequestURL(branch.Name, "") +} + +func (self *BranchesController) copyPullRequestURL() error { + url, err := self.getPullRequestURL() if err != nil { return err }