mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-05 00:59:19 +02:00
Pass todo flag to EditRebaseTodo
Not used yet, we pass an empty string everywhere, to match the previous behavior. Just extracting this into a separate commit to make the next one smaller.
This commit is contained in:
@ -306,7 +306,7 @@ func secondaryPatchPanelUpdateOpts(c *ControllerCommon) *types.ViewUpdateOpts {
|
||||
|
||||
func (self *LocalCommitsController) squashDown(selectedCommits []*models.Commit, startIdx int, endIdx int) error {
|
||||
if self.isRebasing() {
|
||||
return self.updateTodos(todo.Squash, selectedCommits)
|
||||
return self.updateTodos(todo.Squash, "", selectedCommits)
|
||||
}
|
||||
|
||||
self.c.Confirm(types.ConfirmOpts{
|
||||
@ -315,7 +315,7 @@ func (self *LocalCommitsController) squashDown(selectedCommits []*models.Commit,
|
||||
HandleConfirm: func() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.SquashingStatus, func(gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.SquashCommitDown)
|
||||
return self.interactiveRebase(todo.Squash, startIdx, endIdx)
|
||||
return self.interactiveRebase(todo.Squash, "", startIdx, endIdx)
|
||||
})
|
||||
},
|
||||
})
|
||||
@ -325,7 +325,7 @@ func (self *LocalCommitsController) squashDown(selectedCommits []*models.Commit,
|
||||
|
||||
func (self *LocalCommitsController) fixup(selectedCommits []*models.Commit, startIdx int, endIdx int) error {
|
||||
if self.isRebasing() {
|
||||
return self.updateTodos(todo.Fixup, selectedCommits)
|
||||
return self.updateTodos(todo.Fixup, "", selectedCommits)
|
||||
}
|
||||
|
||||
self.c.Confirm(types.ConfirmOpts{
|
||||
@ -334,7 +334,7 @@ func (self *LocalCommitsController) fixup(selectedCommits []*models.Commit, star
|
||||
HandleConfirm: func() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.FixingStatus, func(gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.FixupCommit)
|
||||
return self.interactiveRebase(todo.Fixup, startIdx, endIdx)
|
||||
return self.interactiveRebase(todo.Fixup, "", startIdx, endIdx)
|
||||
})
|
||||
},
|
||||
})
|
||||
@ -469,14 +469,14 @@ func (self *LocalCommitsController) drop(selectedCommits []*models.Commit, start
|
||||
|
||||
self.context().SetSelectionRangeAndMode(selectedIdx, rangeStartIdx, rangeSelectMode)
|
||||
|
||||
return self.updateTodos(todo.Drop, nonUpdateRefTodos)
|
||||
return self.updateTodos(todo.Drop, "", nonUpdateRefTodos)
|
||||
},
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
return self.updateTodos(todo.Drop, selectedCommits)
|
||||
return self.updateTodos(todo.Drop, "", selectedCommits)
|
||||
}
|
||||
|
||||
isMerge := selectedCommits[0].IsMerge()
|
||||
@ -490,7 +490,7 @@ func (self *LocalCommitsController) drop(selectedCommits []*models.Commit, start
|
||||
if isMerge {
|
||||
return self.dropMergeCommit(startIdx)
|
||||
}
|
||||
return self.interactiveRebase(todo.Drop, startIdx, endIdx)
|
||||
return self.interactiveRebase(todo.Drop, "", startIdx, endIdx)
|
||||
})
|
||||
},
|
||||
})
|
||||
@ -505,13 +505,13 @@ func (self *LocalCommitsController) dropMergeCommit(commitIdx int) error {
|
||||
|
||||
func (self *LocalCommitsController) edit(selectedCommits []*models.Commit, startIdx int, endIdx int) error {
|
||||
if self.isRebasing() {
|
||||
return self.updateTodos(todo.Edit, selectedCommits)
|
||||
return self.updateTodos(todo.Edit, "", selectedCommits)
|
||||
}
|
||||
|
||||
commits := self.c.Model().Commits
|
||||
if !commits[endIdx].IsMerge() {
|
||||
selectionRangeAndMode := self.getSelectionRangeAndMode()
|
||||
err := self.c.Git().Rebase.InteractiveRebase(commits, startIdx, endIdx, todo.Edit)
|
||||
err := self.c.Git().Rebase.InteractiveRebase(commits, startIdx, endIdx, todo.Edit, "")
|
||||
return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions(
|
||||
err,
|
||||
types.RefreshOptions{
|
||||
@ -552,7 +552,7 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit(
|
||||
}
|
||||
}
|
||||
if len(todos) > 0 {
|
||||
err := self.updateTodos(todo.Edit, todos)
|
||||
err := self.updateTodos(todo.Edit, "", todos)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -612,20 +612,20 @@ func (self *LocalCommitsController) findCommitForQuickStartInteractiveRebase() (
|
||||
|
||||
func (self *LocalCommitsController) pick(selectedCommits []*models.Commit) error {
|
||||
if self.isRebasing() {
|
||||
return self.updateTodos(todo.Pick, selectedCommits)
|
||||
return self.updateTodos(todo.Pick, "", selectedCommits)
|
||||
}
|
||||
|
||||
panic("should be disabled when not rebasing")
|
||||
}
|
||||
|
||||
func (self *LocalCommitsController) interactiveRebase(action todo.TodoCommand, startIdx int, endIdx int) error {
|
||||
func (self *LocalCommitsController) interactiveRebase(action todo.TodoCommand, flag string, startIdx int, endIdx int) error {
|
||||
// When performing an action that will remove the selected commits, we need to select the
|
||||
// next commit down (which will end up at the start index after the action is performed)
|
||||
if action == todo.Drop || action == todo.Fixup || action == todo.Squash {
|
||||
self.context().SetSelection(startIdx)
|
||||
}
|
||||
|
||||
err := self.c.Git().Rebase.InteractiveRebase(self.c.Model().Commits, startIdx, endIdx, action)
|
||||
err := self.c.Git().Rebase.InteractiveRebase(self.c.Model().Commits, startIdx, endIdx, action, flag)
|
||||
|
||||
return self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err)
|
||||
}
|
||||
@ -633,8 +633,8 @@ func (self *LocalCommitsController) interactiveRebase(action todo.TodoCommand, s
|
||||
// updateTodos sees if the selected commit is in fact a rebasing
|
||||
// commit meaning you are trying to edit the todo file rather than actually
|
||||
// begin a rebase. It then updates the todo file with that action
|
||||
func (self *LocalCommitsController) updateTodos(action todo.TodoCommand, selectedCommits []*models.Commit) error {
|
||||
if err := self.c.Git().Rebase.EditRebaseTodo(selectedCommits, action); err != nil {
|
||||
func (self *LocalCommitsController) updateTodos(action todo.TodoCommand, flag string, selectedCommits []*models.Commit) error {
|
||||
if err := self.c.Git().Rebase.EditRebaseTodo(selectedCommits, action, flag); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user