diff --git a/pkg/gui/controllers/helpers/branches_helper.go b/pkg/gui/controllers/helpers/branches_helper.go index 364c07f6d..3006ba638 100644 --- a/pkg/gui/controllers/helpers/branches_helper.go +++ b/pkg/gui/controllers/helpers/branches_helper.go @@ -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:] { diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 15b37b0b1..bd07e2c9a 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -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) })