diff options
author | Derek Stevens <nilix@nilfm.cc> | 2023-02-01 23:01:36 -0700 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2023-02-08 00:30:57 +0530 |
commit | b78354aee2f0fef8552896d75e106c915365d3ef (patch) | |
tree | 5e772c82807d226dd4bc69c72f170849402941ae /git/tree.go | |
parent | ee800624f58b26204c1f846a524ccef5a1b4e386 (diff) | |
download | legit-b78354aee2f0fef8552896d75e106c915365d3ef.tar.gz legit-b78354aee2f0fef8552896d75e106c915365d3ef.tar.bz2 legit-b78354aee2f0fef8552896d75e106c915365d3ef.zip |
tree: directories first, add size column, fix ..
Signed-off-by: Derek Stevens <nilix@nilfm.cc>
Diffstat (limited to '')
-rw-r--r-- | git/tree.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/git/tree.go b/git/tree.go index 0ef1f2f..88ad1c1 100644 --- a/git/tree.go +++ b/git/tree.go @@ -19,7 +19,7 @@ func (g *GitRepo) FileTree(path string) ([]NiceTree, error) { } if path == "" { - files = makeNiceTree(tree.Entries) + files = makeNiceTree(tree) } else { o, err := tree.FindEntry(path) if err != nil { @@ -32,7 +32,7 @@ func (g *GitRepo) FileTree(path string) ([]NiceTree, error) { return nil, err } - files = makeNiceTree(subtree.Entries) + files = makeNiceTree(subtree) } } @@ -48,15 +48,17 @@ type NiceTree struct { IsSubtree bool } -func makeNiceTree(es []object.TreeEntry) []NiceTree { +func makeNiceTree(t *object.Tree) []NiceTree { nts := []NiceTree{} - for _, e := range es { + for _, e := range t.Entries { mode, _ := e.Mode.ToOSFileMode() + sz, _ := t.Size(e.Name) nts = append(nts, NiceTree{ Name: e.Name, Mode: mode.String(), IsFile: e.Mode.IsFile(), + Size: sz, }) } |