Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(git_indexer): count 'Fixed', 'Fixes', 'Fixing', 'hotfix' and 'bugfix' as bug fixes (#3564) (#3567)

Rishabh Mishra5f220f72be74
diff --git a/packages/core/src/repowise/core/ingestion/git_indexer/_constants.py b/packages/core/src/repowise/core/ingestion/git_indexer/_constants.py
index 97773f08e..00b0be7d9 100644
--- a/packages/core/src/repowise/core/ingestion/git_indexer/_constants.py
+++ b/packages/core/src/repowise/core/ingestion/git_indexer/_constants.py
@@ -156,16 +156,19 @@ _COMMIT_CATEGORIES: dict[str, re.Pattern[str]] = {
# INCLUDE pattern and NO EXCLUDE pattern; merge commits are excluded upstream
# (the per-file walk skips ``is_merge``), mirroring the bench's ``--no-merges``.
#
+# Accepts the verb forms ("fix", "fixed", "fixes", "fixing"), compounds
+# ("hotfix", "bugfix"), and issue reference forms ("fixes #12", "fixed #12").
+#
# The one fix definition: the per-file category counts and the evolution
# timeline both label a commit "fix" exactly when this rule does, so every
# fix count the product shows counts the same commits.
_FIX_COMMIT_INCLUDE: tuple[re.Pattern[str], ...] = (
- re.compile(r"\bfix\b", re.IGNORECASE),
+ re.compile(r"\b(?:hot|bug)?fix(?:e[sd]|ing)?\b", re.IGNORECASE),
re.compile(r"\bbug\b", re.IGNORECASE),
re.compile(r"\bpatch\b", re.IGNORECASE),
re.compile(r"\bresolves?\b", re.IGNORECASE),
- re.compile(r"closes?\s+#\d+", re.IGNORECASE),
- re.compile(r"fixes?\s+#\d+", re.IGNORECASE),
+ re.compile(r"\bcloses?\s+#\d+", re.IGNORECASE),
+ re.compile(r"\bfix(?:e[sd])?\s+#\d+", re.IGNORECASE),
)
_FIX_COMMIT_EXCLUDE: tuple[re.Pattern[str], ...] = (
re.compile(r"^Merge ", re.IGNORECASE),
diff --git a/tests/unit/test_git_indexer.py b/tests/unit/test_git_indexer.py
index 3a3b8cc4e..531ca0dad 100644
--- a/tests/unit/test_git_indexer.py
+++ b/tests/unit/test_git_indexer.py
@@ -489,8 +489,10 @@ class TestGitWindowAnchor:
class TestFixCommitClassifier:
- """``is_fix_commit`` must agree byte-for-byte with the benchmark's
- ``lib/defect_counter.find_fix_commits`` keyword rule (product == benchmark)."""
+ """``is_fix_commit`` must agree with the benchmark's
+ ``lib/defect_counter.find_fix_commits`` keyword rule (product == benchmark),
+ including verb inflections ("fixed", "fixes", "fixing") and compounds
+ ("hotfix", "bugfix")."""
def test_include_patterns_match(self) -> None:
from repowise.core.ingestion.git_indexer._constants import is_fix_commit
@@ -501,6 +503,12 @@ class TestFixCommitClassifier:
assert is_fix_commit("closes #123")
assert is_fix_commit("fixes #99 regression")
assert is_fix_commit("squash a nasty bug")
+ assert is_fix_commit("Fixed #36012 -- Made QuerySet.update() respect ...")
+ assert is_fix_commit("Fixes crash when config is empty")
+ assert is_fix_commit("Fixing race in worker shutdown")
+ assert is_fix_commit("Fixed a crash in the pager")
+ assert is_fix_commit("hotfix: restore login")
+ assert is_fix_commit("bugfix: off-by-one in pager")
def test_exclude_overrides_include(self) -> None:
from repowise.core.ingestion.git_indexer._constants import is_fix_commit
@@ -511,12 +519,21 @@ class TestFixCommitClassifier:
assert not is_fix_commit("Merge fix branch")
assert not is_fix_commit("bump deps to fix CVE")
assert not is_fix_commit("fix a typo")
+ assert not is_fix_commit("Fixed typo in docs")
+ assert not is_fix_commit("Fixes lint")
+ assert not is_fix_commit("Fixing formatting in docs")
def test_non_fixes_silent(self) -> None:
from repowise.core.ingestion.git_indexer._constants import is_fix_commit
assert not is_fix_commit("feat: add new endpoint")
assert not is_fix_commit("refactor the walker")
+ assert not is_fix_commit("affixed the label")
+ assert not is_fix_commit("fixture update")
+ assert not is_fix_commit("prefix with namespace")
+ assert not is_fix_commit("postfix expression")
+ assert not is_fix_commit("prefixed #123")
+ assert not is_fix_commit("affixed #123")
assert not is_fix_commit("")