~gitpocket/gitpocket

1

fix(basin): list directories first in trees

commit
9a946d5b6c374595359b9ad615d7d5c850653aa1 browse tree
parent
489315244d78056ad05cbaf3922437938add3957
author
obscurejames <354576047+obscurejames@users.noreply.github.com>
signature
none
date
2026-10-01 22:06 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