Skip to content

Commit 55becb8

Browse files
committed
fix: ignore cursoragent from contributor statistics
1 parent ba61471 commit 55becb8

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/git.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ pub fn get_file_authors(repo_path: &str) -> Result<HashMap<String, String>> {
100100
let author = commit.author().name().unwrap_or("Unknown").to_string();
101101

102102
if let Some(prev) = previous_tree {
103-
let diff = repo.diff_tree_to_tree(Some(&tree), Some(&prev), None)?;
104-
for delta in diff.deltas() {
105-
if let Some(path) = delta.new_file().path().and_then(|p| p.to_str()) {
106-
// Since we walk backwards in time, the first time we see a file changed
107-
// is its latest modification.
108-
file_authors.entry(path.to_string()).or_insert_with(|| author.clone());
103+
if !author.to_lowercase().contains("cursor") {
104+
let diff = repo.diff_tree_to_tree(Some(&tree), Some(&prev), None)?;
105+
for delta in diff.deltas() {
106+
if let Some(path) = delta.new_file().path().and_then(|p| p.to_str()) {
107+
// Since we walk backwards in time, the first time we see a file changed
108+
// is its latest modification.
109+
file_authors.entry(path.to_string()).or_insert_with(|| author.clone());
110+
}
109111
}
110112
}
111113
}
@@ -131,6 +133,9 @@ pub fn get_contributor_stats(repo_path: &str) -> Result<Vec<ContributorStat>> {
131133
let oid = oid?;
132134
let commit = repo.find_commit(oid)?;
133135
let author = commit.author().name().unwrap_or("Unknown").to_string();
136+
if author.to_lowercase().contains("cursor") {
137+
continue;
138+
}
134139
*author_counts.entry(author).or_insert(0) += 1;
135140
}
136141

@@ -161,6 +166,10 @@ pub fn get_contributors_detail(repo_path: &str) -> Result<Vec<ContributorDetail>
161166
let commit = repo.find_commit(oid)?;
162167
let author = commit.author().name().unwrap_or("Unknown").to_string();
163168

169+
if author.to_lowercase().contains("cursor") {
170+
continue;
171+
}
172+
164173
let detail = author_details.entry(author.clone()).or_insert(ContributorDetail {
165174
name: author.clone(),
166175
commits: 0,
@@ -269,6 +278,9 @@ pub fn get_file_blame(repo_path: &str, file_path: &str) -> Result<HashMap<String
269278

270279
for hunk in blame.iter() {
271280
let author = hunk.final_signature().name().unwrap_or("Unknown").to_string();
281+
if author.to_lowercase().contains("cursor") {
282+
continue;
283+
}
272284
let lines = hunk.lines_in_hunk();
273285
*author_lines.entry(author).or_insert(0) += lines;
274286
}

0 commit comments

Comments
 (0)