1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-08 22:36:49 +02:00

Swap position of checkout-commit and checkout-branch menu items (#4238)

- **PR Description**

Fixes #4237.
This commit is contained in:
Stefan Haller
2025-02-10 13:37:34 +01:00
committed by GitHub
2 changed files with 16 additions and 14 deletions

View File

@@ -278,7 +278,17 @@ func (self *RefsHelper) CreateCheckoutMenu(commit *models.Commit) error {
})
hash := commit.Hash
var menuItems []*types.MenuItem
menuItems := []*types.MenuItem{
{
LabelColumns: []string{fmt.Sprintf(self.c.Tr.Actions.CheckoutCommitAsDetachedHead, utils.ShortHash(hash))},
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.CheckoutCommit)
return self.CheckoutRef(hash, types.CheckoutRefOptions{})
},
Key: 'd',
},
}
if len(branches) > 0 {
menuItems = append(menuItems, lo.Map(branches, func(branch *models.Branch, index int) *types.MenuItem {
@@ -304,15 +314,6 @@ func (self *RefsHelper) CreateCheckoutMenu(commit *models.Commit) error {
})
}
menuItems = append(menuItems, &types.MenuItem{
LabelColumns: []string{fmt.Sprintf(self.c.Tr.Actions.CheckoutCommitAsDetachedHead, utils.ShortHash(hash))},
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.CheckoutCommit)
return self.CheckoutRef(hash, types.CheckoutRefOptions{})
},
Key: 'd',
})
return self.c.Menu(types.CreateMenuOptions{
Title: self.c.Tr.Actions.CheckoutBranchOrCommit,
Items: menuItems,

View File

@@ -32,10 +32,11 @@ var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Menu().
Title(Contains("Checkout branch or commit")).
Lines(
Contains("Checkout branch").IsSelected(),
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head"),
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(),
Contains("Checkout branch"),
Contains("Cancel"),
).
Select(Contains("Checkout branch")).
Tooltip(Contains("Disabled: No branches found at selected commit.")).
Select(MatchesRegexp("Checkout commit [a-f0-9]+ as detached head")).
Confirm()
@@ -53,9 +54,9 @@ var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Menu().
Title(Contains("Checkout branch or commit")).
Lines(
Contains("Checkout branch 'branch1'").IsSelected(),
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(),
Contains("Checkout branch 'branch1'"),
Contains("Checkout branch 'master'"),
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head"),
Contains("Cancel"),
).
Select(Contains("Checkout branch 'master'")).