From 205eecc07342adff88fe19e0626510da533d81c0 Mon Sep 17 00:00:00 2001 From: Grzegorz Dlugoszewski Date: Wed, 3 Jun 2020 16:39:22 +0200 Subject: [PATCH] Update branch name sorting to keep master always on top --- pkg/status.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/status.go b/pkg/status.go index 3373558..60aab74 100644 --- a/pkg/status.go +++ b/pkg/status.go @@ -136,8 +136,12 @@ func (r *Repo) loadBranchesStatus() error { return errors.Wrap(err, "Failed iterating over branches") } - // Sort branches by name. It's useful to have them sorted for printing and testing. + // Sort branches by name (but with "master" always at the top). It's useful to have them sorted for printing and testing. sort.Slice(r.Status.Branches, func(i, j int) bool { + if r.Status.Branches[i].Name == "master" { + return true + } + return strings.Compare(r.Status.Branches[i].Name, r.Status.Branches[j].Name) < 0 }) return nil