Git module
maintained by gogs doesn’t support showing blob count for a tree item. This is generated from my patch file, used to have a similar patch for libgit2.
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
| // Size returns the size of the entry.
func (e *TreeEntry) Size() int64 {
e.sizeOnce.Do(func() {
if e.IsTree() {
stdout, err := NewCommand("ls-tree", "-l", e.id.String()).RunInDir(e.parent.repo.path)
if err != nil {
return
}
lines := len(strings.Split(strings.TrimSpace(string(stdout)), "\n"))
e.size = int64(lines)
return
}
stdout, err := NewCommand("cat-file", "-s", e.id.String()).RunInDir(e.parent.repo.path)
if err != nil {
return
}
e.size, _ = strconv.ParseInt(strings.TrimSpace(string(stdout)), 10, 64)
})
return e.size
}
|