Repository navigation
Description
Problem
Not all clones are equally urgent. A 20-line clone that has been modified 40 times in the last 6 months is a much higher-priority fix than a stable 50-line clone that hasn't changed in 2 years. Today dupehound ranks clones by line count — a purely static metric.
Correlating clones with git log churn gives teams an actionable priority order: fix the clones that are actively causing pain first.
Proposed behavior
Add --git-churn flag. When set, dupehound runs git log --follow -p -- <file> to count commits touching each file in the last N days (default 90), then annotates each clone with the total churn score of its instances (sum of commit counts across all instance files).
# Rank clones by git churn (last 90 days, default)
dupehound scan . --git-churn
# Custom window
dupehound scan . --git-churn --churn-days 180
Example output (text format)
Clone list is re-sorted by churn score when --git-churn is active:
dupehound scan . --git-churn --churn-days 90
Top clones (by churn score, last 90 days):
#1 type-2 similarity: 1.00 18 lines 2 instances churn: 47 commits
src/handlers/payment.go:88-105 (31 commits)
src/handlers/refund.go:12-29 (16 commits)
| func validateAmount(v float64) error {
#2 type-1 similarity: 1.00 42 lines 3 instances churn: 28 commits
src/services/auth.go:55-96 (15 commits)
src/services/session.go:10-51 (8 commits)
src/services/oauth.go:200-241 (5 commits)
| func buildTokenClaims(user User) jwt.MapClaims {
#3 type-3 similarity: 0.78 11 lines 2 instances churn: 2 commits
src/utils/old_parser.go:44-54 (1 commit)
src/utils/legacy.go:88-98 (1 commit)
(low churn — low priority)
JSON additions
{
"clones": [
{
"hash": "a1b2c3d4",
"churn_score": 47,
"instances": [
{
"file": "src/handlers/payment.go",
"file_commits_in_window": 31,
...
}
]
}
]
}Graceful degradation
- If
gitis not available or the directory is not a git repo,--git-churnlogs a warning and falls back to the default line-count ranking. No error exit. - If a file has no git history (e.g., untracked), its churn score is
0.
[warn] git not available — --git-churn disabled, falling back to line-count ranking
Performance
git log is called once per unique file in the clone report (not per clone). Results are cached for the duration of the scan. For typical repos with <500 clone-touched files, this adds <2s overhead.
For very large repos, --churn-days 30 reduces log traversal time.
Backward compatibility
--git-churnis opt-in and off by default.- Default ranking (by line count × instances) is unchanged when flag is absent.
--churn-daysis only valid when--git-churnis set; ignored otherwise.- All output formats supported; JSON adds
churn_scoreandfile_commits_in_windowfields.
Activity
feat: extend domain types and CLI flags for new features (#15-#23)
feat(#18,#19,#20,#21,#22,#23): suppression, top-N, diff-aware, dead c…
fix(reporter): cover gaps in #15-#23 and de-noise text/markdown output
docs: add EXAMPLES.md cookbook and link from README
feat(#15-#23): nine enhancements + diff-aware --since rewrite + safet…
machado144 commentedon Apr 8, 2026
Shipped in #24 (merged in 562be6c). The full list of features, tests, and follow-ups is in the PR description.