Skip to content

Commit 80fb3f6

Browse files
committed
fix(hotspot): normalize file paths to match git numstat output
Analysis paths have "./" prefix (e.g. "./src/main.rs") while git log --numstat returns bare paths ("src/main.rs"). Strip the prefix before joining to fix empty hotspot results.
1 parent a180196 commit 80fb3f6

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

crates/codelens-core/src/insight/hotspot.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Change hotspot analysis: churn × complexity.
22
33
use std::collections::HashMap;
4-
use std::path::PathBuf;
4+
use std::path::{Path, PathBuf};
55

66
use serde::Serialize;
77

@@ -57,12 +57,21 @@ pub fn analyze(
5757
total_commits: usize,
5858
top_n: usize,
5959
) -> HotspotReport {
60-
let stats_map: HashMap<&PathBuf, _> = analysis.files.iter().map(|f| (&f.path, f)).collect();
60+
// Normalize paths: strip leading "./" so analysis paths match git paths
61+
let stats_map: HashMap<&Path, _> = analysis
62+
.files
63+
.iter()
64+
.map(|f| {
65+
let p: &Path = f.path.strip_prefix("./").unwrap_or(&f.path);
66+
(p, f)
67+
})
68+
.collect();
6169

6270
let mut hotspots: Vec<FileHotspot> = churns
6371
.iter()
6472
.filter_map(|churn| {
65-
stats_map.get(&churn.path).map(|stats| FileHotspot {
73+
let key: &Path = churn.path.strip_prefix("./").unwrap_or(&churn.path);
74+
stats_map.get(key).map(|stats| FileHotspot {
6675
path: churn.path.clone(),
6776
language: stats.language.clone(),
6877
churn: ChurnMetrics {

0 commit comments

Comments
 (0)