-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- **PR Description** When the user checks out a commit which has a local branch ref attached to it, they can select between checking out the branch or checking out the commit as detached head. If no local branch is attached to the commit, the behavior is like before: They are asked to confirm, if they want to checkout the commit as detached head. Requested in #4115. Note: I tried also to consider remote branches, but because I wasn't able to correlate remote branches to their commits, I deferred it and leave it open for later improvement.
- Loading branch information
Showing
6 changed files
with
145 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package commit | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var Checkout = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Checkout a commit as a detached head, or checkout an existing branch at a commit", | ||
ExtraCmdArgs: []string{}, | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) {}, | ||
SetupRepo: func(shell *Shell) { | ||
shell.EmptyCommit("one") | ||
shell.EmptyCommit("two") | ||
shell.NewBranch("branch1") | ||
shell.NewBranch("branch2") | ||
shell.EmptyCommit("three") | ||
shell.EmptyCommit("four") | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
t.Views().Commits(). | ||
Focus(). | ||
Lines( | ||
Contains("four").IsSelected(), | ||
Contains("three"), | ||
Contains("two"), | ||
Contains("one"), | ||
). | ||
PressPrimaryAction() | ||
|
||
t.ExpectPopup().Menu(). | ||
Title(Contains("Checkout branch or commit")). | ||
Lines( | ||
Contains("Checkout branch").IsSelected(), | ||
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head"), | ||
Contains("Cancel"), | ||
). | ||
Tooltip(Contains("Disabled: No branches found at selected commit.")). | ||
Select(MatchesRegexp("Checkout commit [a-f0-9]+ as detached head")). | ||
Confirm() | ||
t.Views().Branches().Lines( | ||
Contains("* (HEAD detached at"), | ||
Contains("branch2"), | ||
Contains("branch1"), | ||
Contains("master"), | ||
) | ||
|
||
t.Views().Commits(). | ||
NavigateToLine(Contains("two")). | ||
PressPrimaryAction() | ||
|
||
t.ExpectPopup().Menu(). | ||
Title(Contains("Checkout branch or commit")). | ||
Lines( | ||
Contains("Checkout branch 'branch1'").IsSelected(), | ||
Contains("Checkout branch 'master'"), | ||
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head"), | ||
Contains("Cancel"), | ||
). | ||
Select(Contains("Checkout branch 'master'")). | ||
Confirm() | ||
t.Views().Branches().Lines( | ||
Contains("master"), | ||
Contains("branch2"), | ||
Contains("branch1"), | ||
) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters