forked from jesseduffield/lazygit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add an integration test for checkout branch by name fix: fix full ref name of detached head refactor: refactor current branch loader chore: use field name explicitly
- Loading branch information
1 parent
b33ec5a
commit 52a2e4c
Showing
39 changed files
with
150 additions
and
43 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
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ type Branch struct { | |
Pullables string | ||
UpstreamGone bool | ||
Head bool | ||
DetachedHead bool | ||
// if we have a named remote locally this will be the name of that remote e.g. | ||
// 'origin' or 'tiwood'. If we don't have the remote locally it'll look like | ||
// '[email protected]:tiwood/lazygit.git' | ||
|
@@ -19,6 +20,9 @@ type Branch struct { | |
} | ||
|
||
func (b *Branch) FullRefName() string { | ||
if b.DetachedHead { | ||
return b.Name | ||
} | ||
return "refs/heads/" + b.Name | ||
} | ||
|
||
|
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,39 @@ | ||
package branch | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Try to checkout branch by name. Verify that it also works on the branch with the special name @.", | ||
ExtraCmdArgs: "", | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) {}, | ||
SetupRepo: func(shell *Shell) { | ||
shell. | ||
CreateNCommits(3). | ||
NewBranch("@"). | ||
Checkout("master"). | ||
EmptyCommit("blah") | ||
}, | ||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { | ||
input.SwitchToBranchesWindow() | ||
assert.CurrentViewName("localBranches") | ||
|
||
assert.MatchSelectedLine(Contains("master")) | ||
input.NextItem() | ||
assert.MatchSelectedLine(Contains("@")) | ||
input.PressKeys(keys.Branches.CheckoutBranchByName) | ||
assert.InPrompt() | ||
assert.MatchCurrentViewTitle(Equals("Branch name:")) | ||
input.Type("new-branch") | ||
input.Confirm() | ||
assert.InAlert() | ||
assert.MatchCurrentViewContent(Equals("Branch not found. Create a new branch named new-branch?")) | ||
input.Confirm() | ||
|
||
assert.CurrentViewName("localBranches") | ||
assert.MatchSelectedLine(Contains("new-branch")) | ||
}, | ||
}) |
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
1 change: 1 addition & 0 deletions
1
test/integration_new/branch/checkout_by_name/expected/repo/.git_keep/COMMIT_EDITMSG
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 @@ | ||
blah |
Empty file.
1 change: 1 addition & 0 deletions
1
test/integration_new/branch/checkout_by_name/expected/repo/.git_keep/HEAD
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 @@ | ||
ref: refs/heads/new-branch |
Empty file.
12 changes: 12 additions & 0 deletions
12
test/integration_new/branch/checkout_by_name/expected/repo/.git_keep/config
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,12 @@ | ||
[core] | ||
repositoryformatversion = 0 | ||
filemode = true | ||
bare = false | ||
logallrefupdates = true | ||
ignorecase = true | ||
precomposeunicode = true | ||
[user] | ||
email = [email protected] | ||
name = CI | ||
[commit] | ||
gpgSign = false |
1 change: 1 addition & 0 deletions
1
test/integration_new/branch/checkout_by_name/expected/repo/.git_keep/description
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 @@ | ||
Unnamed repository; edit this file 'description' to name the repository. |
Binary file added
BIN
+305 Bytes
test/integration_new/branch/checkout_by_name/expected/repo/.git_keep/index
Binary file not shown.
Empty file.
7 changes: 7 additions & 0 deletions
7
test/integration_new/branch/checkout_by_name/expected/repo/.git_keep/logs/HEAD
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,7 @@ | ||
0000000000000000000000000000000000000000 95efd4ea6ed74b904cd8eeeaa6245ec462372f67 CI <[email protected]> 1665924398 +0900 commit (initial): commit 01 | ||
95efd4ea6ed74b904cd8eeeaa6245ec462372f67 cfc66e0e89b1dc11a927cc453dbee025ff03cf83 CI <[email protected]> 1665924398 +0900 commit: commit 02 | ||
cfc66e0e89b1dc11a927cc453dbee025ff03cf83 6d69ac71e12a83769fca195d0a714435e1f4661a CI <[email protected]> 1665924398 +0900 commit: commit 03 | ||
6d69ac71e12a83769fca195d0a714435e1f4661a 6d69ac71e12a83769fca195d0a714435e1f4661a CI <[email protected]> 1665924398 +0900 checkout: moving from master to @ | ||
6d69ac71e12a83769fca195d0a714435e1f4661a 6d69ac71e12a83769fca195d0a714435e1f4661a CI <[email protected]> 1665924398 +0900 checkout: moving from @ to master | ||
6d69ac71e12a83769fca195d0a714435e1f4661a 18565748bda3ca01a67a92f340705af5a11384ae CI <[email protected]> 1665924398 +0900 commit: blah | ||
18565748bda3ca01a67a92f340705af5a11384ae 6d69ac71e12a83769fca195d0a714435e1f4661a CI <[email protected]> 1665924403 +0900 checkout: moving from master to new-branch |
1 change: 1 addition & 0 deletions
1
test/integration_new/branch/checkout_by_name/expected/repo/.git_keep/logs/refs/heads/@
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 @@ | ||
0000000000000000000000000000000000000000 6d69ac71e12a83769fca195d0a714435e1f4661a CI <[email protected]> 1665924398 +0900 branch: Created from HEAD |
4 changes: 4 additions & 0 deletions
4
test/integration_new/branch/checkout_by_name/expected/repo/.git_keep/logs/refs/heads/master
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,4 @@ | ||
0000000000000000000000000000000000000000 95efd4ea6ed74b904cd8eeeaa6245ec462372f67 CI <[email protected]> 1665924398 +0900 commit (initial): commit 01 | ||
95efd4ea6ed74b904cd8eeeaa6245ec462372f67 cfc66e0e89b1dc11a927cc453dbee025ff03cf83 CI <[email protected]> 1665924398 +0900 commit: commit 02 | ||
cfc66e0e89b1dc11a927cc453dbee025ff03cf83 6d69ac71e12a83769fca195d0a714435e1f4661a CI <[email protected]> 1665924398 +0900 commit: commit 03 | ||
6d69ac71e12a83769fca195d0a714435e1f4661a 18565748bda3ca01a67a92f340705af5a11384ae CI <[email protected]> 1665924398 +0900 commit: blah |
1 change: 1 addition & 0 deletions
1
...ntegration_new/branch/checkout_by_name/expected/repo/.git_keep/logs/refs/heads/new-branch
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 @@ | ||
0000000000000000000000000000000000000000 6d69ac71e12a83769fca195d0a714435e1f4661a CI <[email protected]> 1665924403 +0900 branch: Created from refs/heads/@ |
Binary file added
BIN
+30 Bytes
...heckout_by_name/expected/repo/.git_keep/objects/06/47fe4b7302efbfb235b8f0681b592cc3389d36
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
...heckout_by_name/expected/repo/.git_keep/objects/18/565748bda3ca01a67a92f340705af5a11384ae
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
Binary file added
BIN
+30 Bytes
...heckout_by_name/expected/repo/.git_keep/objects/3b/f868a389d0073e715e848f0ee33d71064539ca
Binary file not shown.
Binary file added
BIN
+30 Bytes
...heckout_by_name/expected/repo/.git_keep/objects/47/d78ad7a27fc7fe483389512ebf7ea34c5514bc
Binary file not shown.
Binary file added
BIN
+55 Bytes
...heckout_by_name/expected/repo/.git_keep/objects/55/3197193920043fb04f3e39e825916990955204
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
...heckout_by_name/expected/repo/.git_keep/objects/6d/69ac71e12a83769fca195d0a714435e1f4661a
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,3 @@ | ||
x��= | ||
1@a�bzAf�gD����d��q�%��w`���'K���06U�X��Ė4WO�9'm� ]Dݛ%�f͛�H�5q�*D��Y�W�*��:iə��e�i��4�����ԓ,� | ||
c`�'8"#���SC��?��;� |
Binary file added
BIN
+117 Bytes
...heckout_by_name/expected/repo/.git_keep/objects/95/efd4ea6ed74b904cd8eeeaa6245ec462372f67
Binary file not shown.
Binary file added
BIN
+81 Bytes
...heckout_by_name/expected/repo/.git_keep/objects/a0/2c4b36b68df7081152282cf1aabcab7b24e69b
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
...heckout_by_name/expected/repo/.git_keep/objects/cf/c66e0e89b1dc11a927cc453dbee025ff03cf83
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
Binary file added
BIN
+108 Bytes
...heckout_by_name/expected/repo/.git_keep/objects/e6/db1f58c2bb5ead41049a8ef3910360eead21e2
Binary file not shown.
Oops, something went wrong.