mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
Use UpstreamBranch for opening pull requests
This commit is contained in:
committed by
Jesse Duffield
parent
25160b671e
commit
4d258bd981
@ -296,7 +296,10 @@ func (self *BranchesController) promptToCheckoutWorktree(worktree *models.Worktr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *BranchesController) handleCreatePullRequest(selectedBranch *models.Branch) error {
|
func (self *BranchesController) handleCreatePullRequest(selectedBranch *models.Branch) error {
|
||||||
return self.createPullRequest(selectedBranch.Name, "")
|
if !selectedBranch.IsTrackingRemote() {
|
||||||
|
return self.c.ErrorMsg(self.c.Tr.PullRequestNoUpstream)
|
||||||
|
}
|
||||||
|
return self.createPullRequest(selectedBranch.UpstreamBranch, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BranchesController) handleCreatePullRequestMenu(selectedBranch *models.Branch) error {
|
func (self *BranchesController) handleCreatePullRequestMenu(selectedBranch *models.Branch) error {
|
||||||
@ -655,7 +658,7 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra
|
|||||||
{
|
{
|
||||||
LabelColumns: fromToLabelColumns(branch.Name, self.c.Tr.DefaultBranch),
|
LabelColumns: fromToLabelColumns(branch.Name, self.c.Tr.DefaultBranch),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.createPullRequest(branch.Name, "")
|
return self.handleCreatePullRequest(branch)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -663,7 +666,7 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra
|
|||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.c.Prompt(types.PromptOpts{
|
return self.c.Prompt(types.PromptOpts{
|
||||||
Title: branch.Name + " →",
|
Title: branch.Name + " →",
|
||||||
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetBranchNameSuggestionsFunc(),
|
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRemoteBranchesSuggestionsFunc("/"),
|
||||||
HandleConfirm: func(targetBranchName string) error {
|
HandleConfirm: func(targetBranchName string) error {
|
||||||
return self.createPullRequest(branch.Name, targetBranchName)
|
return self.createPullRequest(branch.Name, targetBranchName)
|
||||||
},
|
},
|
||||||
@ -678,7 +681,10 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra
|
|||||||
&types.MenuItem{
|
&types.MenuItem{
|
||||||
LabelColumns: fromToLabelColumns(checkedOutBranch.Name, selectedBranch.Name),
|
LabelColumns: fromToLabelColumns(checkedOutBranch.Name, selectedBranch.Name),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.createPullRequest(checkedOutBranch.Name, selectedBranch.Name)
|
if !checkedOutBranch.IsTrackingRemote() || !selectedBranch.IsTrackingRemote() {
|
||||||
|
return self.c.ErrorMsg(self.c.Tr.PullRequestNoUpstream)
|
||||||
|
}
|
||||||
|
return self.createPullRequest(checkedOutBranch.UpstreamBranch, selectedBranch.UpstreamBranch)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -224,6 +224,7 @@ type TranslationSet struct {
|
|||||||
FwdNoUpstream string
|
FwdNoUpstream string
|
||||||
FwdNoLocalUpstream string
|
FwdNoLocalUpstream string
|
||||||
FwdCommitsToPush string
|
FwdCommitsToPush string
|
||||||
|
PullRequestNoUpstream string
|
||||||
ErrorOccurred string
|
ErrorOccurred string
|
||||||
NoRoom string
|
NoRoom string
|
||||||
YouAreHere string
|
YouAreHere string
|
||||||
@ -1019,6 +1020,7 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
FwdNoUpstream: "Cannot fast-forward a branch with no upstream",
|
FwdNoUpstream: "Cannot fast-forward a branch with no upstream",
|
||||||
FwdNoLocalUpstream: "Cannot fast-forward a branch whose remote is not registered locally",
|
FwdNoLocalUpstream: "Cannot fast-forward a branch whose remote is not registered locally",
|
||||||
FwdCommitsToPush: "Cannot fast-forward a branch with commits to push",
|
FwdCommitsToPush: "Cannot fast-forward a branch with commits to push",
|
||||||
|
PullRequestNoUpstream: "Cannot open a pull request for a branch with no upstream",
|
||||||
ErrorOccurred: "An error occurred! Please create an issue at",
|
ErrorOccurred: "An error occurred! Please create an issue at",
|
||||||
NoRoom: "Not enough room",
|
NoRoom: "Not enough room",
|
||||||
YouAreHere: "YOU ARE HERE",
|
YouAreHere: "YOU ARE HERE",
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package branch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var OpenPullRequestNoUpstream = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Open up a pull request with a missing upstream branch",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().
|
||||||
|
Branches().
|
||||||
|
Focus().
|
||||||
|
Press(keys.Branches.CreatePullRequest)
|
||||||
|
|
||||||
|
t.ExpectPopup().Alert().
|
||||||
|
Title(Equals("Error")).
|
||||||
|
Content(Contains("Cannot open a pull request for a branch with no upstream")).
|
||||||
|
Confirm()
|
||||||
|
},
|
||||||
|
})
|
@ -39,6 +39,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
branch.CreateTag,
|
branch.CreateTag,
|
||||||
branch.Delete,
|
branch.Delete,
|
||||||
branch.DetachedHead,
|
branch.DetachedHead,
|
||||||
|
branch.OpenPullRequestNoUpstream,
|
||||||
branch.OpenWithCliArg,
|
branch.OpenWithCliArg,
|
||||||
branch.Rebase,
|
branch.Rebase,
|
||||||
branch.RebaseAbortOnConflict,
|
branch.RebaseAbortOnConflict,
|
||||||
|
Reference in New Issue
Block a user