6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-04 15:39:46 +00:00

Update branch name sorting to keep master always on top

This commit is contained in:
Grzegorz Dlugoszewski
2020-06-03 16:39:22 +02:00
parent 142fdf1844
commit 205eecc073

View File

@@ -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