1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-28 16:02:01 +03:00

Move LocalBranchSortOrder and RemoteBranchSortOrder to user config

At the same time, we change the defaults for both of them to "date" (they were
"recency" and "alphabetical", respectively, before). This is the reason we need
to touch so many integration tests. For some of them I decided to adapt the test
assertions to the changed sort order; for others, I added a SetupConfig step to
set the order back to "recency" so that I don't have to change what the test
does (e.g. how many SelectNextItem() calls are needed to get to a certain
branch).
This commit is contained in:
Stefan Haller
2025-07-07 15:37:05 +02:00
parent d79283656d
commit 703256e92d
35 changed files with 161 additions and 66 deletions

View File

@ -33,8 +33,8 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
}).
Lines(
MatchesRegexp(`\*.*new-branch`).IsSelected(),
Contains("master"),
Contains("@"),
Contains("master"),
)
},
})

View File

@ -9,7 +9,9 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Try all combination of local and remote branch deletions",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shell.
CloneIntoRemote("origin").

View File

@ -10,7 +10,8 @@ var DeleteMultiple = NewIntegrationTest(NewIntegrationTestArgs{
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetAppState().LocalBranchSortOrder = "alphabetic"
config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical"
config.GetUserConfig().Git.RemoteBranchSortOrder = "alphabetical"
},
SetupRepo: func(shell *Shell) {
shell.

View File

@ -12,7 +12,7 @@ var DeleteWhileFiltering = NewIntegrationTest(NewIntegrationTestArgs{
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetAppState().LocalBranchSortOrder = "alphabetic"
config.GetUserConfig().Git.LocalBranchSortOrder = "alphabetical"
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")

View File

@ -10,7 +10,9 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rebase onto another branch, deal with the conflicts.",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shared.MergeConflictsSetup(shell)
},

View File

@ -10,7 +10,9 @@ var RebaseAbortOnConflict = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rebase onto another branch, abort when there are conflicts.",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shared.MergeConflictsSetup(shell)
},

View File

@ -10,7 +10,9 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rebase onto another branch, deal with the conflicts. Also mark a commit to be dropped before continuing.",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shared.MergeConflictsSetup(shell)
// adding a couple additional commits so that we can drop one

View File

@ -10,7 +10,9 @@ var RebaseCancelOnConflict = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rebase onto another branch, cancel when there are conflicts.",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shared.MergeConflictsSetup(shell)
},

View File

@ -10,7 +10,9 @@ var RebaseConflictsFixBuildErrors = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rebase onto another branch, deal with the conflicts. While continue prompt is showing, fix build errors; get another prompt when continuing.",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shared.MergeConflictsSetup(shell)
},

View File

@ -9,7 +9,9 @@ var RebaseFromMarkedBase = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rebase onto another branch from a marked base commit",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shell.
NewBranch("base-branch").

View File

@ -9,7 +9,9 @@ var ResetToUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Hard reset the current branch to the selected branch upstream",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shell.
CloneIntoRemote("origin").

View File

@ -22,13 +22,13 @@ var SortLocalBranches = NewIntegrationTest(NewIntegrationTestArgs{
Checkout("master")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
// sorted by recency by default
// sorted by date by default
t.Views().Branches().
Focus().
Lines(
Contains("master").IsSelected(),
Contains("third"),
Contains("second"),
Contains("third"),
Contains("first"),
).
SelectNextItem() // to test that the selection jumps back to the top when sorting
@ -38,20 +38,20 @@ var SortLocalBranches = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Menu().Title(Equals("Sort order")).
Lines(
Contains("r () Recency").IsSelected(),
Contains("r ( ) Recency").IsSelected(),
Contains("a ( ) Alphabetical"),
Contains("d ( ) Date"),
Contains("d () Date"),
Contains(" Cancel"),
).
Select(Contains("-committerdate")).
Select(Contains("Recency")).
Confirm()
t.Views().Branches().
IsFocused().
Lines(
Contains("master").IsSelected(),
Contains("second"),
Contains("third"),
Contains("second"),
Contains("first"),
)
@ -60,9 +60,9 @@ var SortLocalBranches = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Menu().Title(Equals("Sort order")).
Lines(
Contains("r ( ) Recency").IsSelected(),
Contains("r () Recency").IsSelected(),
Contains("a ( ) Alphabetical"),
Contains("d () Date"),
Contains("d ( ) Date"),
Contains(" Cancel"),
).
Select(Contains("refname")).

View File

@ -27,13 +27,13 @@ var SortRemoteBranches = NewIntegrationTest(NewIntegrationTestArgs{
).
PressEnter()
// sorted alphabetically by default
// sorted by date by default
t.Views().RemoteBranches().
IsFocused().
Lines(
Contains("first").IsSelected(),
Contains("second"),
Contains("second").IsSelected(),
Contains("third"),
Contains("first"),
).
SelectNextItem() // to test that the selection jumps back to the first when sorting
@ -42,19 +42,19 @@ var SortRemoteBranches = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Menu().Title(Equals("Sort order")).
Lines(
Contains("a () Alphabetical").IsSelected(),
Contains("d ( ) Date"),
Contains("a ( ) Alphabetical").IsSelected(),
Contains("d () Date"),
Contains(" Cancel"),
).
Select(Contains("-committerdate")).
Select(Contains("Alphabetical")).
Confirm()
t.Views().RemoteBranches().
IsFocused().
Lines(
Contains("second").IsSelected(),
Contains("first").IsSelected(),
Contains("second"),
Contains("third"),
Contains("first"),
)
},
})

View File

@ -9,7 +9,9 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Cherry pick commits from the subcommits view, without conflicts",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shell.
EmptyCommit("base").

View File

@ -10,7 +10,9 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Cherry pick commits from the subcommits view, with conflicts",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shared.MergeConflictsSetup(shell)
},

View File

@ -11,6 +11,7 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetAppState().GitLogShowGraph = "never"
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shell.

View File

@ -9,7 +9,9 @@ var CherryPickMerge = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Cherry pick a merge commit",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shell.
EmptyCommit("base").

View File

@ -9,7 +9,9 @@ var CherryPickRange = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Cherry pick range of commits from the subcommits view, without conflicts",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
SetupRepo: func(shell *Shell) {
shell.
EmptyCommit("base").

View File

@ -42,8 +42,8 @@ var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
Confirm()
t.Views().Branches().Lines(
Contains("* (HEAD detached at"),
Contains("branch2"),
Contains("branch1"),
Contains("branch2"),
Contains("master"),
)
@ -63,8 +63,8 @@ var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
Confirm()
t.Views().Branches().Lines(
Contains("master"),
Contains("branch2"),
Contains("branch1"),
Contains("branch2"),
)
},
})

View File

@ -24,6 +24,8 @@ var CheckForConflicts = NewIntegrationTest(NewIntegrationTestArgs{
},
},
}
cfg.GetUserConfig().Git.LocalBranchSortOrder = "recency"
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().

View File

@ -43,9 +43,9 @@ var SuggestionsCommand = NewIntegrationTest(NewIntegrationTestArgs{
Focus().
Lines(
Contains("branch-four").IsSelected(),
Contains("branch-one"),
Contains("branch-three"),
Contains("branch-two"),
Contains("branch-one"),
).
Press("a")
@ -59,8 +59,8 @@ var SuggestionsCommand = NewIntegrationTest(NewIntegrationTestArgs{
Lines(
Contains("branch-three"),
Contains("branch-four").IsSelected(),
Contains("branch-two"),
Contains("branch-one"),
Contains("branch-two"),
)
},
})

View File

@ -43,9 +43,9 @@ var SuggestionsPreset = NewIntegrationTest(NewIntegrationTestArgs{
Focus().
Lines(
Contains("branch-four").IsSelected(),
Contains("branch-one"),
Contains("branch-three"),
Contains("branch-two"),
Contains("branch-one"),
).
Press("a")
@ -59,8 +59,8 @@ var SuggestionsPreset = NewIntegrationTest(NewIntegrationTestArgs{
Lines(
Contains("branch-three"),
Contains("branch-four").IsSelected(),
Contains("branch-two"),
Contains("branch-one"),
Contains("branch-two"),
)
},
})

View File

@ -21,9 +21,9 @@ var FilterUpdatesWhenModelChanges = NewIntegrationTest(NewIntegrationTestArgs{
Focus().
Lines(
Contains("checked-out-branch").IsSelected(),
Contains("other"),
Contains("branch-to-delete"),
Contains("master"),
Contains("other"),
).
FilterOrSearch("branch").
Lines(
@ -65,9 +65,9 @@ var FilterUpdatesWhenModelChanges = NewIntegrationTest(NewIntegrationTestArgs{
PressEscape().
Lines(
Contains("checked-out-branch").IsSelected(),
Contains("other"),
Contains("master"),
Contains("new-branch"),
Contains("other"),
)
},
})

View File

@ -35,8 +35,8 @@ var NestedFilter = NewIntegrationTest(NewIntegrationTestArgs{
Focus().
Lines(
Contains(`branch-bronze`).IsSelected(),
Contains(`branch-silver`),
Contains(`branch-gold`),
Contains(`branch-silver`),
).
FilterOrSearch("sil").
Lines(
@ -148,8 +148,8 @@ var NestedFilter = NewIntegrationTest(NewIntegrationTestArgs{
}).
Lines(
Contains(`branch-bronze`),
Contains(`branch-silver`).IsSelected(),
Contains(`branch-gold`),
Contains(`branch-silver`).IsSelected(),
)
},
})