mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-23 00:39:13 +02:00
start breaking up git struct
This commit is contained in:
@ -31,7 +31,7 @@ func (gui *Gui) branchesRenderToMain() error {
|
||||
if branch == nil {
|
||||
task = NewRenderStringTask(gui.Tr.NoBranchesThisRepo)
|
||||
} else {
|
||||
cmdObj := gui.GitCommand.GetBranchGraphCmdObj(branch.Name)
|
||||
cmdObj := gui.GitCommand.Branch.GetGraphCmdObj(branch.Name)
|
||||
|
||||
task = NewRunPtyTask(cmdObj.GetCmd())
|
||||
}
|
||||
@ -103,7 +103,7 @@ func (gui *Gui) handleCopyPullRequestURLPress() error {
|
||||
|
||||
branch := gui.getSelectedBranch()
|
||||
|
||||
branchExistsOnRemote := gui.GitCommand.CheckRemoteBranchExists(branch.Name)
|
||||
branchExistsOnRemote := gui.GitCommand.Remote.CheckRemoteBranchExists(branch.Name)
|
||||
|
||||
if !branchExistsOnRemote {
|
||||
return gui.surfaceError(errors.New(gui.Tr.NoBranchOnRemote))
|
||||
@ -146,7 +146,7 @@ func (gui *Gui) handleForceCheckout() error {
|
||||
prompt: message,
|
||||
handleConfirm: func() error {
|
||||
gui.logAction(gui.Tr.Actions.ForceCheckoutBranch)
|
||||
if err := gui.GitCommand.Checkout(branch.Name, commands.CheckoutOptions{Force: true}); err != nil {
|
||||
if err := gui.GitCommand.Branch.Checkout(branch.Name, commands.CheckoutOptions{Force: true}); err != nil {
|
||||
_ = gui.surfaceError(err)
|
||||
}
|
||||
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
||||
@ -176,7 +176,7 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions)
|
||||
}
|
||||
|
||||
return gui.WithWaitingStatus(waitingStatus, func() error {
|
||||
if err := gui.GitCommand.Checkout(ref, cmdOptions); err != nil {
|
||||
if err := gui.GitCommand.Branch.Checkout(ref, cmdOptions); err != nil {
|
||||
// note, this will only work for english-language git commands. If we force git to use english, and the error isn't this one, then the user will receive an english command they may not understand. I'm not sure what the best solution to this is. Running the command once in english and a second time in the native language is one option
|
||||
|
||||
if options.onRefNotFound != nil && strings.Contains(err.Error(), "did not match any file(s) known to git") {
|
||||
@ -190,15 +190,15 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions)
|
||||
title: gui.Tr.AutoStashTitle,
|
||||
prompt: gui.Tr.AutoStashPrompt,
|
||||
handleConfirm: func() error {
|
||||
if err := gui.GitCommand.StashSave(gui.Tr.StashPrefix + ref); err != nil {
|
||||
if err := gui.GitCommand.Stash.Save(gui.Tr.StashPrefix + ref); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
if err := gui.GitCommand.Checkout(ref, cmdOptions); err != nil {
|
||||
if err := gui.GitCommand.Branch.Checkout(ref, cmdOptions); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
|
||||
onSuccess()
|
||||
if err := gui.GitCommand.StashDo(0, "pop"); err != nil {
|
||||
if err := gui.GitCommand.Stash.Pop(0); err != nil {
|
||||
if err := gui.refreshSidePanels(refreshOptions{mode: BLOCK_UI}); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -254,7 +254,7 @@ func (gui *Gui) createNewBranchWithName(newBranchName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := gui.GitCommand.NewBranch(newBranchName, branch.Name); err != nil {
|
||||
if err := gui.GitCommand.Branch.New(newBranchName, branch.Name); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ func (gui *Gui) deleteNamedBranch(selectedBranch *models.Branch, force bool) err
|
||||
prompt: message,
|
||||
handleConfirm: func() error {
|
||||
gui.logAction(gui.Tr.Actions.DeleteBranch)
|
||||
if err := gui.GitCommand.DeleteBranch(selectedBranch.Name, force); err != nil {
|
||||
if err := gui.GitCommand.Branch.Delete(selectedBranch.Name, force); err != nil {
|
||||
errMessage := err.Error()
|
||||
if !force && strings.Contains(errMessage, "git branch -D ") {
|
||||
return gui.deleteNamedBranch(selectedBranch, true)
|
||||
@ -315,7 +315,7 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if gui.GitCommand.IsHeadDetached() {
|
||||
if gui.GitCommand.Branch.IsHeadDetached() {
|
||||
return gui.createErrorPanel("Cannot merge branch in detached head state. You might have checked out a commit directly or a remote branch, in which case you should checkout the local branch you want to be on")
|
||||
}
|
||||
checkedOutBranchName := gui.getCheckedOutBranch().Name
|
||||
@ -335,7 +335,7 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
|
||||
prompt: prompt,
|
||||
handleConfirm: func() error {
|
||||
gui.logAction(gui.Tr.Actions.Merge)
|
||||
err := gui.GitCommand.Merge(branchName, commands.MergeOpts{})
|
||||
err := gui.GitCommand.Branch.Merge(branchName, commands.MergeOpts{})
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
},
|
||||
})
|
||||
@ -377,7 +377,7 @@ func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error {
|
||||
prompt: prompt,
|
||||
handleConfirm: func() error {
|
||||
gui.logAction(gui.Tr.Actions.RebaseBranch)
|
||||
err := gui.GitCommand.RebaseBranch(selectedBranchName)
|
||||
err := gui.GitCommand.Rebase.RebaseBranch(selectedBranchName)
|
||||
return gui.handleGenericMergeCommandResult(err)
|
||||
},
|
||||
})
|
||||
@ -396,7 +396,7 @@ func (gui *Gui) handleFastForward() error {
|
||||
return gui.createErrorPanel(gui.Tr.FwdCommitsToPush)
|
||||
}
|
||||
|
||||
upstream, err := gui.GitCommand.GetUpstreamForBranch(branch.Name)
|
||||
upstream, err := gui.GitCommand.Branch.GetUpstream(branch.Name)
|
||||
if err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
@ -421,7 +421,7 @@ func (gui *Gui) handleFastForward() error {
|
||||
_ = gui.pullWithLock(PullFilesOptions{action: action, FastForwardOnly: true})
|
||||
} else {
|
||||
gui.logAction(action)
|
||||
err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName, gui.promptUserForCredential)
|
||||
err := gui.GitCommand.Sync.FastForward(branch.Name, remoteName, remoteBranchName)
|
||||
gui.handleCredentialsPopup(err)
|
||||
_ = gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{BRANCHES}})
|
||||
}
|
||||
@ -450,7 +450,7 @@ func (gui *Gui) handleRenameBranch() error {
|
||||
initialContent: branch.Name,
|
||||
handleConfirm: func(newBranchName string) error {
|
||||
gui.logAction(gui.Tr.Actions.RenameBranch)
|
||||
if err := gui.GitCommand.RenameBranch(branch.Name, newBranchName); err != nil {
|
||||
if err := gui.GitCommand.Branch.Rename(branch.Name, newBranchName); err != nil {
|
||||
return gui.surfaceError(err)
|
||||
}
|
||||
|
||||
@ -519,7 +519,7 @@ func (gui *Gui) handleNewBranchOffCurrentItem() error {
|
||||
initialContent: prefilledName,
|
||||
handleConfirm: func(response string) error {
|
||||
gui.logAction(gui.Tr.Actions.CreateBranch)
|
||||
if err := gui.GitCommand.NewBranch(sanitizedBranchName(response), item.ID()); err != nil {
|
||||
if err := gui.GitCommand.Branch.New(sanitizedBranchName(response), item.ID()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user