Skip to content

KeyError in auth2new when using --since/--until #122

@silkyanteater

Description

@silkyanteater

When using --since and --until flags, git fame crashes with a KeyError after processing completes.

Traceback:

Processing: 100%|████████████████████████████████| 2455/2455 [00:24<00:00, 98.25file/s]
Traceback (most recent call last):
  File "/home/silky/.local/bin/git-fame", line 6, in <module>
    sys.exit(main())
  File "/home/silky/.local/lib/python3.10/site-packages/gitfame/_gitfame.py", line 519, in main
    run(args)
  File "/home/silky/.local/lib/python3.10/site-packages/gitfame/_gitfame.py", line 467, in run
    for res in mapper(statter, gitdirs):
  File "/home/silky/.local/lib/python3.10/site-packages/gitfame/_gitfame.py", line 360, in _get_auth_stats
    i = auth_stats.setdefault(auth2new[auth], defaultdict(int, files=set(), ctimes=[]))
KeyError: 'R.T. <rt@gmail.com>'

To reproduce:

git fame --since="2025-01-01" --until="2025-12-31" --format=tabulate

on a repository where some surviving lines of code are attributed (via git blame) to authors who have no commits within the --since/--until date range.

Cause:

git blame --line-porcelain --since/--until may attribute surviving lines to authors whose commits fall outside the date range (boundary commits not fully stripped by RE_BLAME_BOUNDS). These authors end up in auth_stats but not in auth2new (which is populated from git shortlog --since/--until), causing the KeyError when remapping author keys for name-only or email-only display.

This is a different root cause than #115 (which was about blank emails).

Environment:

  • Python 3.10
  • git-fame 3.1.1
  • Ubuntu (WSL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions