diff --git a/Cargo.lock b/Cargo.lock index 03e99ea..3df0860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -237,7 +237,7 @@ checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "loki-cli" -version = "2.5.0" +version = "2.6.0" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 85afd07..1e9dfeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/README.md b/README.md index 61b9eef..0310289 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main.rs b/src/main.rs index 31b829b..2a744bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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")] @@ -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 ); } @@ -464,7 +471,7 @@ fn collect_raw_commits( range: &TimeRange, ) -> Result, String> { let mut git_args: Vec = 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());