39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import subprocess
|
|
from collections import defaultdict
|
|
|
|
REPO = "/root/troupe-standup"
|
|
|
|
def parse(extra):
|
|
counts = defaultdict(int)
|
|
ls = subprocess.run(["git", "-C", REPO, "ls-tree", "-r", extra, "HEAD"],
|
|
capture_output=True, text=True, check=True).stdout
|
|
for line in ls.splitlines():
|
|
if not line.strip():
|
|
continue
|
|
head, sep, path = line.partition("\t")
|
|
fhead = head.split()
|
|
top = "(root)" if "/" not in path else path.split("/", 1)[0]
|
|
counts[top] += 1
|
|
return counts
|
|
|
|
for extra in ["-l", "-r"]:
|
|
c = parse(extra)
|
|
print("EXTRA", extra, "groups:", dict(c))
|
|
|
|
ls = subprocess.run(["git", "-C", REPO, "ls-tree", "-r", "HEAD"],
|
|
capture_output=True, text=True, check=True).stdout
|
|
lines = [l for l in ls.splitlines() if l.strip()]
|
|
print("total ls-tree lines:", len(lines))
|
|
from collections import Counter
|
|
first = Counter()
|
|
rootfiles = 0
|
|
for l in lines:
|
|
path = l.partition("\t")[2]
|
|
top = "(root)" if "/" not in path else path.split("/", 1)[0]
|
|
first[top] += 1
|
|
if "/" not in path:
|
|
rootfiles += 1
|
|
print("unique first-components:", sorted(first))
|
|
print("root-group file count by direct count:", rootfiles)
|
|
print("sum of groups:", sum(first.values()))
|