~gitpocket/gitpocket

8

fix(basin): list directories first in trees

commit
42c2b34320535d9e3f87de60136a7cb0376248f3 browse tree
parent
5cd691cb1f8b0634805c4921a383eeeaae1fad70
author
~james <[email protected]>
signature
none
date
2026-10-05 20:37 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