mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-08 04:04:22 +02:00
Disallow pulling/pushing a branch while the branch is pushed or pulled
This commit is contained in:
parent
fd9d7cb7bb
commit
67d6447e12
@ -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()
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user