diff --git a/devstats/DOCS-comparison.md b/devstats/DOCS-comparison.md index b5f8425..462adf6 100644 --- a/devstats/DOCS-comparison.md +++ b/devstats/DOCS-comparison.md @@ -4,9 +4,9 @@ Generated 2026-11-27 by `python -m devstats compare --write` (utils/devstats). Article: https://veszelovszki.com/a/tpe/ (Cmdr, posted 2026-10-24). - kuhy: every repo under ~/src, each piece of work once (worktrees, clones - and rewritten copies folded in), commits on the default branch (local and - origin tips), `--no-merges`, authored by kuhy's address (agent-made commits - included). Committer date, local time. + and rewritten copies folded in), commits on the local default branch + (nothing read from origin/, nothing fetched), `--no-merges`, authored by + kuhy's address (agent-made commits included). Committer date, local time. - Net LoC = insertions − deletions of code paths. Docs/translations are left out of the headline like the article's; the "+docs" row adds them back. - Cmdr's figures are per calendar day; the baseline (194) is per day with a @@ -17,37 +17,37 @@ Article: https://veszelovszki.com/a/tpe/ (Cmdr, posted 2026-10-24). | window | row | kuhy net LoC/day | ins/day | del/day | Cmdr LoC/day | |---|---|---|---|---|---| -| 30 d | raw | 25,808 | 35,818 | 10,010 | 12,000 | -| 30 d | ×0.67 | 17,291 | 23,998 | 6,707 | 8,040 | -| 30 d | +docs | 26,220 | 37,070 | 10,850 | — | -| 90 d | raw | 19,533 | 24,524 | 4,992 | 9,700 | -| 90 d | ×0.67 | 13,087 | 16,431 | 3,344 | 6,499 | -| 90 d | +docs | 19,955 | 25,384 | 5,429 | — | -| 300 d ≈ lifetime (10 mo) | raw | 7,579 | 11,075 | 3,497 | 4,500 | -| 300 d ≈ lifetime (10 mo) | ×0.67 | 5,078 | 7,421 | 2,343 | 3,015 | -| 300 d ≈ lifetime (10 mo) | +docs | 7,923 | 11,795 | 3,871 | — | +| 30 d | raw | 24,639 | 34,238 | 9,599 | 12,000 | +| 30 d | ×0.67 | 16,508 | 22,939 | 6,431 | 8,040 | +| 30 d | +docs | 25,006 | 35,426 | 10,420 | — | +| 90 d | raw | 19,191 | 24,082 | 4,890 | 9,700 | +| 90 d | ×0.67 | 12,858 | 16,135 | 3,277 | 6,499 | +| 90 d | +docs | 19,598 | 24,920 | 5,322 | — | +| 300 d ≈ lifetime (10 mo) | raw | 7,568 | 11,044 | 3,475 | 4,500 | +| 300 d ≈ lifetime (10 mo) | ×0.67 | 5,071 | 7,399 | 2,328 | 3,015 | +| 300 d ≈ lifetime (10 mo) | +docs | 7,909 | 11,756 | 3,848 | — | ## Per active day vs the 194 LoC/workday baseline | window | active days | row | kuhy net LoC/active day | baseline LoC/workday | kuhy ÷ 194 | kuhy commits/active day | Cmdr commits/workday | |---|---|---|---|---|---|---|---| -| 30 d | 24 | raw | 32,260 | 194 | 166.3× | 146 | 160 | -| 30 d | 24 | ×0.67 | 21,614 | 194 | 111.4× | | | -| 90 d | 77 | raw | 22,830 | 194 | 117.7× | 82 | — | -| 90 d | 77 | ×0.67 | 15,296 | 194 | 78.8× | | | -| 300 d ≈ lifetime (10 mo) | 181 | raw | 12,561 | 194 | 64.7× | 47 | 55 | -| 300 d ≈ lifetime (10 mo) | 181 | ×0.67 | 8,416 | 194 | 43.4× | | | +| 30 d | 24 | raw | 30,799 | 194 | 158.8× | 141 | 160 | +| 30 d | 24 | ×0.67 | 20,635 | 194 | 106.4× | | | +| 90 d | 77 | raw | 22,431 | 194 | 115.6× | 81 | — | +| 90 d | 77 | ×0.67 | 15,029 | 194 | 77.5× | | | +| 300 d ≈ lifetime (10 mo) | 181 | raw | 12,544 | 194 | 64.7× | 47 | 55 | +| 300 d ≈ lifetime (10 mo) | 181 | ×0.67 | 8,405 | 194 | 43.3× | | | ## Totals | window | net code LoC | insertions | deletions | net +docs | excluded share | commits | tags | tags/week | Cmdr releases/week | repos with ≥1 tag | |---|---|---|---|---|---|---|---|---|---|---| -| 30 d | 774,242 | 1,074,555 | 300,313 | 786,589 | 23% | 3,511 | 725 | 169.2 | ~2 | 26 | -| 90 d | 1,757,944 | 2,207,196 | 449,252 | 1,795,922 | 23% | 6,340 | 1226 | 95.4 | ~2 | 28 | -| 300 d ≈ lifetime (10 mo) | 2,273,591 | 3,322,648 | 1,049,057 | 2,376,996 | 33% | 8,562 | 1661 | 38.8 | ~2 | 31 | +| 30 d | 739,179 | 1,027,137 | 287,958 | 750,168 | 23% | 3,391 | 726 | 169.4 | ~2 | 26 | +| 90 d | 1,727,195 | 2,167,336 | 440,141 | 1,763,815 | 23% | 6,219 | 1227 | 95.4 | ~2 | 28 | +| 300 d ≈ lifetime (10 mo) | 2,270,522 | 3,313,061 | 1,042,539 | 2,372,569 | 32% | 8,442 | 1662 | 38.8 | ~2 | 31 | ## Exclude list (first match wins) -- excluded: `node_modules/`, `vendor/`, `third_party/`, `addons/`, `.venv/`, `.dart_tool/`, `dist/`, `build/`, `generated/`, `htmlcov/`, `coverage/`, `__snapshots__/`, `data/`, `assets/`, `fixtures/`, `*.lock`, `*.lockb`, `package-lock.json`, `npm-shrinkwrap.json`, `pnpm-lock.yaml`, `go.sum`, `*.g.dart`, `*.freezed.dart`, `*.mocks.dart`, `*.gr.dart`, `*.pb.go`, `*_pb2.py`, `*.min.js`, `*.min.css`, `*.map`, `coverage.xml`, `lcov.info`, `*.lcov`, `*.import`, `*.uid`, `*.snap`, `*.json`, `*.jsonl`, `*.ndjson`, `*.geojson`, `*.csv`, `*.tsv`, `*.txt`, `*.tcx`, `*.gpx`, `*.tres`, `*.svg`, `*.log` +- excluded: `node_modules/`, `vendor/`, `third_party/`, `addons/`, `.venv/`, `.dart_tool/`, `dist/`, `build/`, `generated/`, `htmlcov/`, `coverage/`, `__snapshots__/`, `*.lock`, `*.lockb`, `package-lock.json`, `npm-shrinkwrap.json`, `pnpm-lock.yaml`, `go.sum`, `*.g.dart`, `*.freezed.dart`, `*.mocks.dart`, `*.gr.dart`, `*.pb.go`, `*_pb2.py`, `*.min.js`, `*.min.css`, `*.map`, `coverage.xml`, `lcov.info`, `*.lcov`, `*.import`, `*.uid`, `*.snap`, `data/`, `assets/`, `fixtures/`, `*.json`, `*.jsonl`, `*.ndjson`, `*.geojson`, `*.csv`, `*.tsv`, `*.txt`, `*.tcx`, `*.gpx`, `*.tres`, `*.svg`, `*.log` - docs: `docs/`, `doc/`, `l10n/`, `locales/`, `i18n/`, `translations/`, `*.md`, `*.mdx`, `*.rst`, `*.adoc`, `*.arb`, `*.po`, `*.pot`, `LICENSE*`, `COPYING*` -- code: `godot_dev_tools/`, `package.json`, `tsconfig*.json`, `jsconfig.json`, `deno.json`, `requirements*.txt`, `CMakeLists.txt` +- code: `godot_dev_tools/`, `package.json`, `tsconfig*.json`, `jsconfig.json`, `deno.json`, `requirements*.txt`, `CMakeLists.txt`, `*.py`, `*.dart`, `*.ts`, `*.tsx`, `*.js`, `*.jsx`, `*.mjs`, `*.gd`, `*.go`, `*.kt`, `*.kts`, `*.java`, `*.sh`, `*.c`, `*.h`, `*.cpp`, `*.rs`, `*.lua` diff --git a/devstats/cli.py b/devstats/cli.py index e1d9a93..7db8d66 100644 --- a/devstats/cli.py +++ b/devstats/cli.py @@ -29,7 +29,8 @@ def build_parser() -> argparse.ArgumentParser: sub = parser.add_subparsers(dest="cmd", required=True) cmp = sub.add_parser("compare", help="print kuhy's 30/90/300-day numbers beside the article's") cmp.add_argument("--root", action="append", type=Path, default=[], - help="directory whose child repos are walked (repeatable; default ~/src)") + help="directory (or repo) whose child repos are walked (repeatable; " + "given roots replace the default ~/src)") cmp.add_argument("--email", action="append", default=[], help=f"extra author email to count (repeatable; {DEFAULT_EMAIL} always counts)") cmp.add_argument("--by-repo", nargs="?", type=int, const=10, default=0, metavar="N", diff --git a/devstats/excludes.py b/devstats/excludes.py index 0ae3fd8..6b67840 100644 --- a/devstats/excludes.py +++ b/devstats/excludes.py @@ -2,8 +2,10 @@ One ordered constant, first match wins. A pattern ending in "/" matches any directory component of the path; any other pattern is a glob on the file name. -Excluded directories come first so nothing inside node_modules/ or addons/ is -rescued by a later rule; the code keeps come before the file excludes so +Vendored/build directories come first so nothing inside node_modules/ or +addons/ is rescued by a later rule; source files (by extension) are kept +before the data/, assets/ and fixtures/ directory rules, so lib/data/*.dart +and a fixtures/ fake binary in Python stay code; the code keeps come before the file excludes so package.json survives `*.json`; translation dirs come before `*.json` so locales/en.json counts as docs, like the article's "+800k translations and docs". @@ -13,7 +15,7 @@ Judgment calls, calibrated on the 30-day top-40 churn list (2026-11-27): - Godot `addons/` is vendored (GUT, copies of dev_tools) except the source of kuhy's own addon under `godot_dev_tools/`; `*.tres` is data; `*.import`/`*.uid` are generated; `*.tscn` scenes stay code (authored structure). -- `fixtures/` is test data; test code itself stays. +- `fixtures/` is test data; test code (source extensions) inside it stays. """ from __future__ import annotations @@ -26,13 +28,12 @@ Bucket = Literal["code", "docs", "excluded"] RULES: tuple[tuple[Bucket, str], ...] = ( # kuhy's own Godot addon source (utils/godot_dev_tools); games carry vendored copies ("code", "godot_dev_tools/"), - # vendored, generated and data directories (any depth) + # vendored and build-output directories (any depth): everything inside goes *( ("excluded", d) for d in ( "node_modules/", "vendor/", "third_party/", "addons/", ".venv/", ".dart_tool/", "dist/", "build/", "generated/", "htmlcov/", "coverage/", "__snapshots__/", - "data/", "assets/", "fixtures/", ) ), # config files that would otherwise fall under a data glob below @@ -56,6 +57,14 @@ RULES: tuple[tuple[Bucket, str], ...] = ( "*_pb2.py", "*.min.js", "*.min.css", "*.map", "coverage.xml", "lcov.info", "*.lcov", "*.import", "*.uid", "*.snap") ), + # source files stay code even inside the data dirs below (lib/data/*.dart) + *( + ("code", f) + for f in ("*.py", "*.dart", "*.ts", "*.tsx", "*.js", "*.jsx", "*.mjs", "*.gd", "*.go", + "*.kt", "*.kts", "*.java", "*.sh", "*.c", "*.h", "*.cpp", "*.rs", "*.lua") + ), + # data and asset directories: whatever is not source in them is data + *(("excluded", d) for d in ("data/", "assets/", "fixtures/")), # data and assets *( ("excluded", f) diff --git a/devstats/refs.py b/devstats/refs.py index e2d6945..0f17fe8 100644 --- a/devstats/refs.py +++ b/devstats/refs.py @@ -1,9 +1,9 @@ """Default-branch resolution from refs on disk (never fetches). -The commits counted are the union of the local default branch and its -`origin/` remote-tracking ref: work landed with `git push origin HEAD:main` -from a worktree only moves the remote-tracking ref, while unpushed local work -only moves the local one, and both are kuhy's output. +Only the LOCAL default branch is counted (kuhy's spec: "read local refs +only"). origin/HEAD only names the branch. When the `origin/` tracking ref is +newer, the caller warns: work landed with `git push origin HEAD:main` from a +worktree is then missing from the count until the checkout is pulled. """ from __future__ import annotations @@ -29,7 +29,7 @@ class Ref: @dataclass(frozen=True) class DefaultRefs: - """The default branch name, the refs to log, and how stale the local tip is.""" + """The default branch name, the local ref to log, and how stale it is.""" branch: str | None log_refs: tuple[str, ...] @@ -53,17 +53,14 @@ def tag_times(refs: dict[str, Ref]) -> list[tuple[str, int]]: def resolve(refs: dict[str, Ref]) -> DefaultRefs: - """origin/HEAD's branch, else main, else master; local and origin tips of it.""" + """origin/HEAD's branch, else main, else master: the first that exists locally.""" head = refs.get(_ORIGIN + "HEAD") candidates = [head.symref.removeprefix(_ORIGIN)] if head and head.symref else [] for branch in (*candidates, "main", "master"): local, remote = refs.get("refs/heads/" + branch), refs.get(_ORIGIN + branch) - if local or remote: - log_refs = tuple( - n for n, r in (("refs/heads/" + branch, local), (_ORIGIN + branch, remote)) if r - ) + if local: behind = None - if local and remote and local.sha != remote.sha and remote.ts > local.ts: + if remote and local.sha != remote.sha and remote.ts > local.ts: behind = round((remote.ts - local.ts) / 86_400, 1) - return DefaultRefs(branch, log_refs, behind) + return DefaultRefs(branch, ("refs/heads/" + branch,), behind) return DefaultRefs(None, (), None) diff --git a/devstats/render.py b/devstats/render.py index 8826a3b..b43f151 100644 --- a/devstats/render.py +++ b/devstats/render.py @@ -98,9 +98,9 @@ Generated {date} by `python -m devstats compare --write` (utils/devstats). Article: {A.URL} (Cmdr, posted 2026-10-24). - kuhy: every repo under ~/src, each piece of work once (worktrees, clones - and rewritten copies folded in), commits on the default branch (local and - origin tips), `--no-merges`, authored by kuhy's address (agent-made commits - included). Committer date, local time. + and rewritten copies folded in), commits on the local default branch + (nothing read from origin/, nothing fetched), `--no-merges`, authored by + kuhy's address (agent-made commits included). Committer date, local time. - Net LoC = insertions − deletions of code paths. Docs/translations are left out of the headline like the article's; the "+docs" row adds them back. - Cmdr's figures are per calendar day; the baseline (194) is per day with a diff --git a/devstats/tests/test_cli.py b/devstats/tests/test_cli.py index d2050f3..1db27b1 100644 --- a/devstats/tests/test_cli.py +++ b/devstats/tests/test_cli.py @@ -20,7 +20,7 @@ def src(make_repo, tmp_path: Path) -> Path: bot.commit({"bot.py": None}, NOW - 50 * DAY + 1) # dates out of order on purpose: kept by --since bot.commit({"x.py": lines(10)}, NOW - 2 * DAY, email="ppolgon@gmail.com") bot.tag("v1", NOW - DAY, annotated=True) - bot.commit({"pushed.py": lines(3)}, NOW - DAY) # pushed from a worktree: only origin has it + bot.commit({"pushed.py": lines(3)}, NOW - DAY) # only origin has it: not counted (local refs only) run(bot.path, "update-ref", "refs/remotes/origin/main", "HEAD") run(bot.path, "update-ref", "refs/heads/main", "HEAD~1") # local main behind origin run(bot.path, "worktree", "add", "-q", str(tmp_path / "src" / "sb-wt-a"), "-b", "wt") diff --git a/devstats/tests/test_excludes.py b/devstats/tests/test_excludes.py index f1b0fed..b209e56 100644 --- a/devstats/tests/test_excludes.py +++ b/devstats/tests/test_excludes.py @@ -46,7 +46,11 @@ from devstats.excludes import RULES, classify ("tools/eval/data/reference.json", "excluded"), ("assets/audio/MANIFEST.json", "excluded"), ("tests/fixtures/run.tcx", "excluded"), - ("tests/fixtures/host/q.py", "excluded"), + ("tests/fixtures/host/q.py", "code"), + ("app/lib/data/repo.dart", "code"), + ("app/lib/data/repo.g.dart", "excluded"), + ("assets/fonts/Inter.ttf.txt", "excluded"), + ("web/build/main.js", "excluded"), ("games/chips/sea.tres", "excluded"), ("report.csv", "excluded"), # docs and translations diff --git a/devstats/tests/test_refs.py b/devstats/tests/test_refs.py index ce4e5bb..ea68a2a 100644 --- a/devstats/tests/test_refs.py +++ b/devstats/tests/test_refs.py @@ -20,7 +20,7 @@ def test_origin_head_names_the_branch_and_both_tips_are_logged() -> None: } got = resolve(refs) assert got.branch == "trunk" - assert got.log_refs == ("refs/heads/trunk", "refs/remotes/origin/trunk") + assert got.log_refs == ("refs/heads/trunk",) assert got.behind_days == 2.5 @@ -31,9 +31,10 @@ def test_falls_back_to_main_then_master_without_origin() -> None: assert got.behind_days is None -def test_origin_only_branch_is_still_counted() -> None: - got = resolve({"refs/remotes/origin/main": ref(1)}) - assert got.log_refs == ("refs/remotes/origin/main",) +def test_origin_only_branch_is_not_counted() -> None: + got = resolve({"refs/remotes/origin/HEAD": ref(0, symref="refs/remotes/origin/main"), + "refs/remotes/origin/main": ref(1)}) + assert (got.branch, got.log_refs) == (None, ()) def test_no_default_branch() -> None: