summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/controllers/branches_controller.go31
-rw-r--r--pkg/gui/controllers/helpers/merge_and_rebase_helper.go16
2 files changed, 20 insertions, 27 deletions
diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go
index c975d500d..62eda703e 100644
--- a/pkg/gui/controllers/branches_controller.go
+++ b/pkg/gui/controllers/branches_controller.go
@@ -100,15 +100,13 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty
DisplayOnScreen: true,
},
{
- Key: opts.GetKey(opts.Config.Branches.RebaseBranch),
- Handler: opts.Guards.OutsideFilterMode(self.rebase),
- GetDisabledReason: self.require(
- self.singleItemSelected(self.notRebasingOntoSelf),
- ),
- Description: self.c.Tr.RebaseBranch,
- Tooltip: self.c.Tr.RebaseBranchTooltip,
- OpensMenu: true,
- DisplayOnScreen: true,
+ Key: opts.GetKey(opts.Config.Branches.RebaseBranch),
+ Handler: opts.Guards.OutsideFilterMode(self.withItem(self.rebase)),
+ GetDisabledReason: self.require(self.singleItemSelected()),
+ Description: self.c.Tr.RebaseBranch,
+ Tooltip: self.c.Tr.RebaseBranchTooltip,
+ OpensMenu: true,
+ DisplayOnScreen: true,
},
{
Key: opts.GetKey(opts.Config.Branches.MergeIntoCurrentBranch),
@@ -634,19 +632,8 @@ func (self *BranchesController) merge() error {
return self.c.Helpers().MergeAndRebase.MergeRefIntoCheckedOutBranch(selectedBranchName)
}
-func (self *BranchesController) rebase() error {
- selectedBranchName := self.context().GetSelected().Name
- return self.c.Helpers().MergeAndRebase.RebaseOntoRef(selectedBranchName)
-}
-
-func (self *BranchesController) notRebasingOntoSelf(branch *models.Branch) *types.DisabledReason {
- selectedBranchName := branch.Name
- checkedOutBranch := self.c.Helpers().Refs.GetCheckedOutRef().Name
- if selectedBranchName == checkedOutBranch {
- return &types.DisabledReason{Text: self.c.Tr.CantRebaseOntoSelf}
- }
-
- return nil
+func (self *BranchesController) rebase(branch *models.Branch) error {
+ return self.c.Helpers().MergeAndRebase.RebaseOntoRef(branch.Name)
}
func (self *BranchesController) fastForward(branch *models.Branch) error {
diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go
index 4bffcfa99..35903ea64 100644
--- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go
+++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go
@@ -235,10 +235,15 @@ func (self *MergeAndRebaseHelper) PromptToContinueRebase() error {
func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
checkedOutBranch := self.refsHelper.GetCheckedOutRef().Name
+ var disabledReason *types.DisabledReason
+ if checkedOutBranch == ref {
+ disabledReason = &types.DisabledReason{Text: self.c.Tr.CantRebaseOntoSelf}
+ }
menuItems := []*types.MenuItem{
{
- Label: self.c.Tr.SimpleRebase,
- Key: 's',
+ Label: self.c.Tr.SimpleRebase,
+ Key: 's',
+ DisabledReason: disabledReason,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.RebaseBranch)
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(task gocui.Task) error {
@@ -258,9 +263,10 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
},
},
{
- Label: self.c.Tr.InteractiveRebase,
- Key: 'i',
- Tooltip: self.c.Tr.InteractiveRebaseTooltip,
+ Label: self.c.Tr.InteractiveRebase,
+ Key: 'i',
+ DisabledReason: disabledReason,
+ Tooltip: self.c.Tr.InteractiveRebaseTooltip,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.RebaseBranch)
baseCommit := self.c.Modes().MarkedBaseCommit.GetHash()