diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-27 19:14:47 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-30 18:35:23 +1000 |
commit | 0a410141ae9aa1fdf857889c55137f957ed87263 (patch) | |
tree | 20cb33266fe7624554c8ca2d40a39845983a6730 /pkg/commands | |
parent | e356b29b4a7888a24bca6b3784b9df5b2e3fa34c (diff) |
Fix test by making branches appear deterministically
This fixes pkg/integration/tests/worktree/rebase.go which was failing on old git versions due to a difference in
order of branches that don't have recency values
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/git_commands/branch_loader.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/commands/git_commands/branch_loader.go b/pkg/commands/git_commands/branch_loader.go index cb284f67f..7c91c1cbc 100644 --- a/pkg/commands/git_commands/branch_loader.go +++ b/pkg/commands/git_commands/branch_loader.go @@ -81,6 +81,12 @@ outer: } } + // Sort branches that don't have a recency value alphabetically + // (we're really doing this for the sake of deterministic behaviour across git versions) + slices.SortFunc(branches, func(a *models.Branch, b *models.Branch) bool { + return a.Name < b.Name + }) + branches = slices.Prepend(branches, branchesWithRecency...) foundHead := false |