From 0a410141ae9aa1fdf857889c55137f957ed87263 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Thu, 27 Jul 2023 19:14:47 +1000 Subject: [PATCH] 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 --- pkg/commands/git_commands/branch_loader.go | 6 ++++++ 1 file changed, 6 insertions(+) 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