Skip to content

Commit dc11c26

Browse files
Add optional first-parent flag to repo stats
Co-authored-by: kylewrader <kylewrader@gmail.com>
1 parent faa6b17 commit dc11c26

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "loki-cli"
3-
version = "1.8.0"
3+
version = "1.9.0"
44
authors = ["Kyle W. Rader"]
55
description = "Loki: 🚀 A Git productivity tool"
66
homepage = "https://github.com/kyle-rader/loki-cli"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Analyze commits reachable from HEAD to see who has been landing work in a reposi
9595

9696
- `--name` filters by author display name (repeatable, case-insensitive).
9797
- `--email` filters by author email (repeatable, case-insensitive).
98+
- `--first-parent` limits the analysis to first-parent commits.
9899

99100
#### Example
100101
```

src/main.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ struct RepoStatsOptions {
7373
#[clap(long, default_value_t = 20)]
7474
top: usize,
7575

76+
/// Only include first-parent commits.
77+
#[clap(long, default_value = "false")]
78+
first_parent: bool,
79+
7680
/// Only include commits authored by these names (repeatable, case-insensitive fuzzy match).
7781
#[clap(long = "name", value_name = "NAME")]
7882
names: Vec<String>,
@@ -231,10 +235,11 @@ fn repo_stats(options: &RepoStatsOptions) -> Result<(), String> {
231235
let email_filters_lower: Vec<String> =
232236
options.emails.iter().map(|s| s.to_lowercase()).collect();
233237

234-
let mut git_args: Vec<String> = vec![
235-
"log".to_string(),
236-
"--pretty=format:%ct%x09%an%x09%ae".to_string(),
237-
];
238+
let mut git_args: Vec<String> = vec!["log".to_string()];
239+
if options.first_parent {
240+
git_args.push("--first-parent".to_string());
241+
}
242+
git_args.push("--pretty=format:%ct%x09%an%x09%ae".to_string());
238243
if let Some(start_ts) = range.start_ts {
239244
git_args.push(format!("--since=@{start_ts}"));
240245
}
@@ -338,10 +343,17 @@ fn repo_stats(options: &RepoStatsOptions) -> Result<(), String> {
338343
progress.finish();
339344

340345
if totals.is_empty() {
341-
println!(
342-
"No commits found between {} and {}.",
343-
range.start_label, range.end_label
344-
);
346+
if options.first_parent {
347+
println!(
348+
"No first-parent commits found between {} and {}.",
349+
range.start_label, range.end_label
350+
);
351+
} else {
352+
println!(
353+
"No commits found between {} and {}.",
354+
range.start_label, range.end_label
355+
);
356+
}
345357
return Ok(());
346358
}
347359

0 commit comments

Comments
 (0)