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(branch_overlap): clarify branch count when scan is truncated (#2934)

Suprovo Mallick (DYNO)10bb6af4deaa
diff --git a/packages/core/src/repowise/core/analysis/branch_overlap.py b/packages/core/src/repowise/core/analysis/branch_overlap.py
index 4d4754cd0..f96e6eed7 100644
--- a/packages/core/src/repowise/core/analysis/branch_overlap.py
+++ b/packages/core/src/repowise/core/analysis/branch_overlap.py
@@ -117,6 +117,12 @@ class BranchOverlap:
"No other open branch edits a file this change edits "
f"({self.scanned} scanned of {self.total})."
)
+ if self.scanned < self.total:
+ not_scanned = self.total - self.scanned
+ return (
+ f"{len(self.branches)} of the {self.scanned} newest branches scanned "
+ f"edit files this change also edits ({not_scanned} of {self.total} not scanned)."
+ )
return (
f"{len(self.branches)} of {self.scanned} open branches "
f"({self.total} exist) edit files this change also edits."
diff --git a/tests/unit/analysis/test_branch_overlap.py b/tests/unit/analysis/test_branch_overlap.py
index 57ec875cd..de82a55bb 100644
--- a/tests/unit/analysis/test_branch_overlap.py
+++ b/tests/unit/analysis/test_branch_overlap.py
@@ -15,7 +15,12 @@ import subprocess
import pytest
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
-from repowise.core.analysis.branch_overlap import rank_with_index, scan_branches
+from repowise.core.analysis.branch_overlap import (
+ BranchOverlap,
+ BranchOverlapEntry,
+ rank_with_index,
+ scan_branches,
+)
from repowise.core.git_refs import ahead_behind_many, files_by_ref
from repowise.core.persistence.database import init_db
from repowise.core.persistence.models import (
@@ -246,6 +251,15 @@ def test_the_summary_counts_the_branches_that_overlap(repo):
)
+def test_the_summary_names_the_sample_and_remainder_when_truncated():
+ entry = BranchOverlapEntry("feature", "2026-01-01", 1700000000, 1, 0, ())
+ overlap = BranchOverlap("main", "cur", (entry,) * 18, scanned=50, total=1649)
+
+ assert overlap.to_dict()["summary"] == (
+ "18 of the 50 newest branches scanned edit files this change also edits (1599 of 1649 not scanned)."
+ )
+
+
# ---------------------------------------------------------------------------
# The bulk read that decides which branches earn an exact diff