~gitpocket/gitpocket

fix(basin): list directories first and sort tree entries case insensitively

commit
f6ae2b8457269cd3b8d443e7a50fd07646e1d8cb browse tree
parent
1623aea6d0b64d591d8340b6cdfcaff885454c65
author
james <j@cpl0.zip>
signature
none
date
2026-11-12 10:36 UTC

1 files changed, +10 −0

git.go modified

@@ -7,6 +7,7 @@ import (
77 "os"
88 "os/exec"
99 "path"
10+ "slices"
1011 "strconv"
1112 "strings"
1213 "time"
@@ -267,6 +268,15 @@ func (g Git) Tree(commit, dir string) ([]Entry, error) {
267268 }
268269 entries = append(entries, e)
269270 }
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+ })
270280 return entries, nil
271281 }
272282