mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
Extract showing an inline status on several branches
Pushing a stack and fast-forwarding a range of branches each show their operation on all the branches involved, with their own copy of the same code. Pulling a stack will need it too, so move it to BranchesHelper. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b7395b1637
commit
6919a2aa47
@@ -449,7 +449,7 @@ func (self *BranchesHelper) FastForwardBranches(branches []*models.Branch) error
|
||||
return err
|
||||
}
|
||||
|
||||
return self.withFastForwardingStatus(branches, fastForward)
|
||||
return self.WithInlineStatusOnBranches(branches, types.ItemOperationFastForwarding, fastForward)
|
||||
}
|
||||
|
||||
// Does the part of FastForwardBranches that looks at the model, and so has to
|
||||
@@ -501,11 +501,12 @@ func (self *BranchesHelper) PrepareFastForward(branches []*models.Branch) (func(
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Runs f with all the given branches shown as being fast-forwarded
|
||||
func (self *BranchesHelper) withFastForwardingStatus(branches []*models.Branch, f func(gocui.Task) error) error {
|
||||
return self.c.WithInlineStatus(branches[0], types.ItemOperationFastForwarding, context.LOCAL_BRANCHES_CONTEXT_KEY, func(task gocui.Task) error {
|
||||
// Runs f on a worker with all the given branches shown as being in the given
|
||||
// operation while it runs
|
||||
func (self *BranchesHelper) WithInlineStatusOnBranches(branches []*models.Branch, operation types.ItemOperation, f func(gocui.Task) error) error {
|
||||
return self.c.WithInlineStatus(branches[0], operation, context.LOCAL_BRANCHES_CONTEXT_KEY, func(task gocui.Task) error {
|
||||
for _, branch := range branches[1:] {
|
||||
self.c.State().SetItemOperation(branch, types.ItemOperationFastForwarding)
|
||||
self.c.State().SetItemOperation(branch, operation)
|
||||
}
|
||||
defer func() {
|
||||
for _, branch := range branches[1:] {
|
||||
|
||||
@@ -383,16 +383,8 @@ func (self *SyncController) pushBranchesAux(currentBranch *models.Branch, branch
|
||||
// Runs f as a push of the current branch, showing it and the other branches
|
||||
// as being pushed while it runs
|
||||
func (self *SyncController) withPushingStatus(currentBranch *models.Branch, otherBranches []*models.Branch, f func(gocui.Task) error) error {
|
||||
return self.c.WithInlineStatus(currentBranch, types.ItemOperationPushing, context.LOCAL_BRANCHES_CONTEXT_KEY, func(task gocui.Task) error {
|
||||
for _, branch := range otherBranches {
|
||||
self.c.State().SetItemOperation(branch, types.ItemOperationPushing)
|
||||
}
|
||||
defer func() {
|
||||
for _, branch := range otherBranches {
|
||||
self.c.State().ClearItemOperation(branch)
|
||||
}
|
||||
}()
|
||||
|
||||
branches := append([]*models.Branch{currentBranch}, otherBranches...)
|
||||
return self.c.Helpers().BranchesHelper.WithInlineStatusOnBranches(branches, types.ItemOperationPushing, func(task gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.Push)
|
||||
return f(task)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user