1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-18 10:02:15 +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

@ -74,7 +74,7 @@ func (self *BranchLoader) Load(reflogCommits []*models.Commit,
) ([]*models.Branch, error) {
branches := self.obtainBranches()
if self.AppState.LocalBranchSortOrder == "recency" {
if self.UserConfig().Git.LocalBranchSortOrder == "recency" {
reflogBranches := self.obtainReflogBranches(reflogCommits)
// loop through reflog branches. If there is a match, merge them, then remove it from the branches and keep it in the reflog branches
branchesWithRecency := make([]*models.Branch, 0)
@ -254,7 +254,7 @@ func (self *BranchLoader) obtainBranches() []*models.Branch {
return nil, false
}
storeCommitDateAsRecency := self.AppState.LocalBranchSortOrder != "recency"
storeCommitDateAsRecency := self.UserConfig().Git.LocalBranchSortOrder != "recency"
return obtainBranch(split, storeCommitDateAsRecency), true
})
}
@ -268,7 +268,7 @@ func (self *BranchLoader) getRawBranches() (string, error) {
)
var sortOrder string
switch strings.ToLower(self.AppState.LocalBranchSortOrder) {
switch strings.ToLower(self.UserConfig().Git.LocalBranchSortOrder) {
case "recency", "date":
sortOrder = "-committerdate"
case "alphabetical":