Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "loki-cli"
version = "2.5.0"
version = "2.6.0"
authors = ["Kyle W. Rader"]
description = "Loki: 🚀 A Git productivity tool"
homepage = "https://github.com/kyle-rader/loki-cli"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Analyze commits reachable from HEAD to see who has been landing work in a reposi

- `--name` filters by author display name (repeatable, case-insensitive).
- `--email` filters by author email (repeatable, case-insensitive).
- `--all` includes all commits (default is first-parent only).
- `--first-parent` restricts the walk to the first-parent chain of HEAD (one tally per merge commit). Default walks all commits reachable from HEAD, relying on patch-id dedup to handle rebased / cherry-picked / migrated history.
- `--no-dedup` disables patch-id deduplication (see below).

#### Patch-id deduplication
Expand Down
21 changes: 14 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,16 @@ struct RepoStatsOptions {
#[clap(long, default_value_t = 20)]
top: usize,

/// Include all commits (disables first-parent-only filtering).
#[clap(long, default_value = "false")]
all: bool,
/// Only count commits on the first-parent chain of HEAD.
///
/// By default `lk repo stats` walks every commit reachable from HEAD
/// (with patch-id deduplication applied so logically-identical commits
/// from rebases / cherry-picks / cross-repo migrations are counted
/// once). Pass `--first-parent` to restrict the walk to the mainline
/// of merges into HEAD — useful when each PR is merged with a merge
/// commit and you want one tally per PR.
#[clap(long, default_value_t = false)]
first_parent: bool,

/// Only include commits authored by these names (repeatable, case-insensitive fuzzy match).
#[clap(long = "name", value_name = "NAME")]
Expand Down Expand Up @@ -384,14 +391,14 @@ fn repo_stats(options: &RepoStatsOptions) -> Result<(), String> {
progress.finish();

if totals.is_empty() {
if options.all {
if options.first_parent {
println!(
"No commits found between {} and {}.",
"No first-parent commits found between {} and {}.",
range.start_label, range.end_label
);
} else {
println!(
"No first-parent commits found between {} and {}.",
"No commits found between {} and {}.",
range.start_label, range.end_label
);
}
Expand Down Expand Up @@ -464,7 +471,7 @@ fn collect_raw_commits(
range: &TimeRange,
) -> Result<Vec<RawCommit>, String> {
let mut git_args: Vec<String> = vec!["log".to_string()];
if !options.all {
if options.first_parent {
git_args.push("--first-parent".to_string());
}
git_args.push("--pretty=format:%H%x09%ct%x09%an%x09%ae".to_string());
Expand Down
Loading