Skip to content

fix: count LOC/files when passing multiple repos - #125

Merged
casperdcl merged 1 commit into
casperdcl:mainfrom
Sanjays2402:fix/multi-repo-blame-path
Jul 31, 2026
Merged

fix: count LOC/files when passing multiple repos#125
casperdcl merged 1 commit into
casperdcl:mainfrom
Sanjays2402:fix/multi-repo-blame-path

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #64.

With more than one gitdir, _get_auth_stats prefixed each filename with the gitdir before passing it to git -C <gitdir> blame, so git was asked for <gitdir>/<gitdir>/<file>. Every blame failed and was swallowed by the surrounding try/except, leaving the default --loc=surviving with zero loc/files/ctimes (commit counts come from shortlog, which is why only those survived — matching @casperdcl's note that --loc=ins,del works).

The prefix is only needed for the reported name, so it now goes to a separate display_fname used for logging and stats_append, while the repo-relative fname is passed to git. The added test runs gitfame over two relative gitdirs and fails on main with KeyError: 'loc'.

This change was prepared with AI assistance; the regression test was run locally and fails without the fix.

@casperdcl casperdcl left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.76%. Comparing base (19956fe) to head (b99f118).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #125      +/-   ##
==========================================
+ Coverage   85.71%   89.76%   +4.05%     
==========================================
  Files           3        3              
  Lines         392      391       -1     
  Branches      104      103       -1     
==========================================
+ Hits          336      351      +15     
+ Misses         45       31      -14     
+ Partials       11        9       -2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

With more than one gitdir, `prefix_gitdir` is set and `_get_auth_stats`
prefixed each filename with the gitdir before passing it to
`git -C <gitdir> blame`, producing `<gitdir>/<gitdir>/<file>`. Every blame
call then failed and was swallowed by the surrounding try/except, so the
default `--loc=surviving` reported zero loc, files and ctimes (commit
counts come from `shortlog` and were unaffected).

The prefix is only needed for the reported name, so it is now applied to
a separate `display_fname` used for logging and `stats_append`, while the
repo-relative `fname` is passed to git.

Adds a regression test running gitfame over two relative gitdirs.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 92.072% (+3.6%) from 88.52% — Sanjays2402:fix/multi-repo-blame-path into casperdcl:main

@casperdcl
casperdcl merged commit 9450ecc into casperdcl:main Jul 31, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fails to count LOC and files when passing multiple repos

3 participants