fix(basin): list directories first and sort tree entries case insensitively
1 files changed, +10 −0
- git.go modified +10 −0
git.go modified
| @@ -7,6 +7,7 @@ import ( | ||
| 7 | 7 | "os" |
| 8 | 8 | "os/exec" |
| 9 | 9 | "path" |
| 10 | + "slices" | |
| 10 | 11 | "strconv" |
| 11 | 12 | "strings" |
| 12 | 13 | "time" |
| @@ -267,6 +268,15 @@ func (g Git) Tree(commit, dir string) ([]Entry, error) { | ||
| 267 | 268 | } |
| 268 | 269 | entries = append(entries, e) |
| 269 | 270 | } |
| 271 | + slices.SortStableFunc(entries, func(a, b Entry) int { | |
| 272 | + if (a.Type == "tree") != (b.Type == "tree") { | |
| 273 | + if a.Type == "tree" { | |
| 274 | + return -1 | |
| 275 | + } | |
| 276 | + return 1 | |
| 277 | + } | |
| 278 | + return strings.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)) | |
| 279 | + }) | |
| 270 | 280 | return entries, nil |
| 271 | 281 | } |
| 272 | 282 | |