Skip to content

Commit 01987c7

Browse files
authored
Merge pull request #33 from kyle-rader/cursor/repo-stats-full-history-95e4
2 parents 02affbd + dc11c26 commit 01987c7

3 files changed

Lines changed: 24 additions & 12 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.7.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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ lk x -- commit -m "Update Readme without running hooks"
9191
```
9292

9393
### `repo stats`
94-
Analyze first-parent commits to see who has been landing work in a repository. All of the filtering flags operate on commit dates.
94+
Analyze commits reachable from HEAD to see who has been landing work in a repository. All of the filtering flags operate on commit dates.
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: 21 additions & 10 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>,
@@ -85,7 +89,7 @@ struct RepoStatsOptions {
8589

8690
#[derive(Debug, Subcommand)]
8791
enum RepoSubcommand {
88-
/// Analyze first-parent commits by author over time.
92+
/// Analyze commits by author over time.
8993
#[clap(name = "stats")]
9094
Stats(RepoStatsOptions),
9195
}
@@ -231,11 +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-
"--first-parent".to_string(),
237-
"--pretty=format:%ct%x09%an%x09%ae".to_string(),
238-
];
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());
239243
if let Some(start_ts) = range.start_ts {
240244
git_args.push(format!("--since=@{start_ts}"));
241245
}
@@ -339,10 +343,17 @@ fn repo_stats(options: &RepoStatsOptions) -> Result<(), String> {
339343
progress.finish();
340344

341345
if totals.is_empty() {
342-
println!(
343-
"No first-parent commits found between {} and {}.",
344-
range.start_label, range.end_label
345-
);
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+
}
346357
return Ok(());
347358
}
348359

0 commit comments

Comments
 (0)