mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
better fast forward
This commit is contained in:
parent
8347dcd671
commit
b42202ea1c
@ -272,12 +272,11 @@ func (c *GitCommand) ResetAndClean() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *GitCommand) GetCurrentBranchUpstreamDifferenceCount() (string, string) {
|
func (c *GitCommand) GetCurrentBranchUpstreamDifferenceCount() (string, string) {
|
||||||
return c.GetCommitDifferences("HEAD", "@{u}")
|
return c.GetCommitDifferences("HEAD", "HEAD@{u}")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GitCommand) GetBranchUpstreamDifferenceCount(branchName string) (string, string) {
|
func (c *GitCommand) GetBranchUpstreamDifferenceCount(branchName string) (string, string) {
|
||||||
upstream := "origin" // hardcoded for now
|
return c.GetCommitDifferences(branchName, branchName+"@{u}")
|
||||||
return c.GetCommitDifferences(branchName, fmt.Sprintf("%s/%s", upstream, branchName))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCommitDifferences checks how many pushables/pullables there are for the
|
// GetCommitDifferences checks how many pushables/pullables there are for the
|
||||||
@ -643,9 +642,8 @@ func (c *GitCommand) ApplyPatch(patch string, flags ...string) error {
|
|||||||
return c.OSCommand.RunCommand(fmt.Sprintf("git apply %s %s", flagStr, c.OSCommand.Quote(filepath)))
|
return c.OSCommand.RunCommand(fmt.Sprintf("git apply %s %s", flagStr, c.OSCommand.Quote(filepath)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GitCommand) FastForward(branchName string) error {
|
func (c *GitCommand) FastForward(branchName string, remoteName string, remoteBranchName string) error {
|
||||||
upstream := "origin" // hardcoding for now
|
return c.OSCommand.RunCommand(fmt.Sprintf("git fetch %s %s:%s", remoteName, remoteBranchName, branchName))
|
||||||
return c.OSCommand.RunCommand(fmt.Sprintf("git fetch %s %s:%s", upstream, branchName, branchName))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GitCommand) RunSkipEditorCommand(command string) error {
|
func (c *GitCommand) RunSkipEditorCommand(command string) error {
|
||||||
|
@ -342,17 +342,27 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error {
|
|||||||
if branch.Pushables != "0" {
|
if branch.Pushables != "0" {
|
||||||
return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("FwdCommitsToPush"))
|
return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("FwdCommitsToPush"))
|
||||||
}
|
}
|
||||||
upstream := "origin" // hardcoding for now
|
|
||||||
|
upstream, err := gui.GitCommand.GetUpstreamForBranch(branch.Name)
|
||||||
|
if err != nil {
|
||||||
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
split := strings.Split(upstream, "/")
|
||||||
|
remoteName := split[0]
|
||||||
|
remoteBranchName := strings.Join(split[1:], "/")
|
||||||
|
|
||||||
message := gui.Tr.TemplateLocalize(
|
message := gui.Tr.TemplateLocalize(
|
||||||
"Fetching",
|
"Fetching",
|
||||||
Teml{
|
Teml{
|
||||||
"from": fmt.Sprintf("%s/%s", upstream, branch.Name),
|
"from": fmt.Sprintf("%s/%s", remoteName, remoteBranchName),
|
||||||
"to": branch.Name,
|
"to": branch.Name,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
go func() {
|
go func() {
|
||||||
_ = gui.createLoaderPanel(gui.g, v, message)
|
_ = gui.createLoaderPanel(gui.g, v, message)
|
||||||
if err := gui.GitCommand.FastForward(branch.Name); err != nil {
|
|
||||||
|
if err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName); err != nil {
|
||||||
_ = gui.createErrorPanel(gui.g, err.Error())
|
_ = gui.createErrorPanel(gui.g, err.Error())
|
||||||
} else {
|
} else {
|
||||||
_ = gui.closeConfirmationPrompt(gui.g, true)
|
_ = gui.closeConfirmationPrompt(gui.g, true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user