diff --git a/Cargo.toml b/Cargo.toml index ef151d2..128ccfb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "loki-cli" -version = "1.7.0" +version = "1.9.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 f46a68a..fbe00ca 100644 --- a/README.md +++ b/README.md @@ -91,10 +91,11 @@ lk x -- commit -m "Update Readme without running hooks" ``` ### `repo stats` -Analyze first-parent commits to see who has been landing work in a repository. All of the filtering flags operate on commit dates. +Analyze commits reachable from HEAD to see who has been landing work in a repository. All of the filtering flags operate on commit dates. - `--name` filters by author display name (repeatable, case-insensitive). - `--email` filters by author email (repeatable, case-insensitive). +- `--first-parent` limits the analysis to first-parent commits. #### Example ``` diff --git a/src/main.rs b/src/main.rs index 8cdc4db..08d6f7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,6 +73,10 @@ struct RepoStatsOptions { #[clap(long, default_value_t = 20)] top: usize, + /// Only include first-parent commits. + #[clap(long, default_value = "false")] + first_parent: bool, + /// Only include commits authored by these names (repeatable, case-insensitive fuzzy match). #[clap(long = "name", value_name = "NAME")] names: Vec, @@ -85,7 +89,7 @@ struct RepoStatsOptions { #[derive(Debug, Subcommand)] enum RepoSubcommand { - /// Analyze first-parent commits by author over time. + /// Analyze commits by author over time. #[clap(name = "stats")] Stats(RepoStatsOptions), } @@ -231,11 +235,11 @@ fn repo_stats(options: &RepoStatsOptions) -> Result<(), String> { let email_filters_lower: Vec = options.emails.iter().map(|s| s.to_lowercase()).collect(); - let mut git_args: Vec = vec![ - "log".to_string(), - "--first-parent".to_string(), - "--pretty=format:%ct%x09%an%x09%ae".to_string(), - ]; + let mut git_args: Vec = vec!["log".to_string()]; + if options.first_parent { + git_args.push("--first-parent".to_string()); + } + git_args.push("--pretty=format:%ct%x09%an%x09%ae".to_string()); if let Some(start_ts) = range.start_ts { git_args.push(format!("--since=@{start_ts}")); } @@ -339,10 +343,17 @@ fn repo_stats(options: &RepoStatsOptions) -> Result<(), String> { progress.finish(); if totals.is_empty() { - println!( - "No first-parent commits found between {} and {}.", - range.start_label, range.end_label - ); + if options.first_parent { + println!( + "No first-parent commits found between {} and {}.", + range.start_label, range.end_label + ); + } else { + println!( + "No commits found between {} and {}.", + range.start_label, range.end_label + ); + } return Ok(()); }