mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-06-20 01:19:23 +02:00
Change "Copy pull request URL to clipboard" command to use existing PR if there is one
This commit is contained in:
@@ -525,16 +525,23 @@ func (self *BranchesController) handleCreatePullRequestMenu(selectedBranch *mode
|
|||||||
return self.createPullRequestMenu(selectedBranch, checkedOutBranch)
|
return self.createPullRequestMenu(selectedBranch, checkedOutBranch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BranchesController) copyPullRequestURL() error {
|
func (self *BranchesController) getPullRequestURL() (string, error) {
|
||||||
branch := self.context().GetSelected()
|
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)
|
branchExistsOnRemote := self.c.Git().Remote.CheckRemoteBranchExists(branch.Name)
|
||||||
|
|
||||||
if !branchExistsOnRemote {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user