Repository navigation
refactor: save a git call when the author is on ignore_authors - #694
Conversation
The author checks asked git whether a commit exists before they read ignore_authors, so an author on the list cost one `git rev-parse` more than in 2.20.4. Read the list first again, and look the commit up only when the list said no; a repository with no commits then asks the list a second time about the identity the first commit will carry. One test of the fallback to the last commit's author ran that lookup against the real repository. It now patches it like the other git calls.
Pre-merge checks:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #694 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 15 15
Lines 2598 2600 +2
Branches 507 508 +1
=========================================
+ Hits 2598 2600 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will improve performance by 27.34%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
Patching has_commits in the fallback test built a mock that costs more than the git call it replaced, by CodSpeed's count. The test now tells _get_author_value that a commit exists, so nothing is looked up.
|



Before: since #692, an author check that gets no message asks git whether a commit exists before it reads
ignore_authors. An author on the list costs one git command more than in 2.20.4. Git commands run bycommit-check --author-name(fromGIT_TRACE) when the last commit is bydependabot[bot], who is on the list:CodSpeed reported two author benchmarks 18% slower on #692; both ran this extra lookup.
After: the same two commands as 2.20.4.
How
AuthorValidator.validatereadsignore_authorsfirst again and looks up whether a commit exists only when the list said no. In a repository with no commits it then asks the list a second time about the identity the first commit will carry, so what fix: check the first commit's author, name author.* in the CC017 advice #692 fixed stays fixed.test_get_author_value_with_email_formatmocks git but ran the commit lookup against the real repository. It now passeshas_head=True, so nothing is looked up. Patching the lookup instead was slower than the git call by CodSpeed's count (callgrind, per run: 1.47M instructions on main, 1.92M with the extra patch, 1.26M withhas_head=True).