diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index 46d553a84..4e3369e0a 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -31,14 +31,16 @@ func NewSyncController( func (self *SyncController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding { bindings := []*types.Binding{ { - Key: opts.GetKey(opts.Config.Universal.Push), - Handler: opts.Guards.NoPopupPanel(self.HandlePush), - Description: self.c.Tr.Push, + Key: opts.GetKey(opts.Config.Universal.Push), + Handler: opts.Guards.NoPopupPanel(self.HandlePush), + GetDisabledReason: self.getDisabledReasonForPushOrPull, + Description: self.c.Tr.Push, }, { - Key: opts.GetKey(opts.Config.Universal.Pull), - Handler: opts.Guards.NoPopupPanel(self.HandlePull), - Description: self.c.Tr.Pull, + Key: opts.GetKey(opts.Config.Universal.Pull), + Handler: opts.Guards.NoPopupPanel(self.HandlePull), + GetDisabledReason: self.getDisabledReasonForPushOrPull, + Description: self.c.Tr.Pull, }, } @@ -57,6 +59,18 @@ func (self *SyncController) HandlePull() error { return self.branchCheckedOut(self.pull)() } +func (self *SyncController) getDisabledReasonForPushOrPull() string { + currentBranch := self.c.Helpers().Refs.GetCheckedOutRef() + if currentBranch != nil { + op := self.c.State().GetItemOperation(currentBranch) + if op != types.ItemOperationNone { + return self.c.Tr.CantPullOrPushSameBranchTwice + } + } + + return "" +} + func (self *SyncController) branchCheckedOut(f func(*models.Branch) error) func() error { return func() error { currentBranch := self.c.Helpers().Refs.GetCheckedOutRef() diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 29f507b3c..8e3a936ce 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -58,6 +58,7 @@ type TranslationSet struct { MergeConflictsTitle string Checkout string CantCheckoutBranchWhilePulling string + CantPullOrPushSameBranchTwice string NoChangedFiles string SoftReset string AlreadyCheckedOutBranch string @@ -848,6 +849,7 @@ func EnglishTranslationSet() TranslationSet { MergeConflictsTitle: "Merge conflicts", Checkout: "Checkout", CantCheckoutBranchWhilePulling: "You cannot checkout another branch while pulling the current branch", + CantPullOrPushSameBranchTwice: "You cannot push or pull a branch while it is already being pushed or pulled", FileFilter: "Filter files by status", FilterStagedFiles: "Show only staged files", FilterUnstagedFiles: "Show only unstaged files",