Added a --no-merges flag so merges can be ignored

master
Wynd 2024-08-17 23:59:44 +03:00
parent 31052bcd37
commit cbb5d07cb4
3 changed files with 13 additions and 0 deletions

View File

@ -42,6 +42,9 @@ $ git-heatmap -r "/path/to/repo" -b "main" -r "/other/repo" -b "test"
# or to comply with the same number of branch lists per repo lists rule from above # or to comply with the same number of branch lists per repo lists rule from above
$ git-heatmap -r "/path/to/repo" -b "main" -r "other/repo" -b "" $ git-heatmap -r "/path/to/repo" -b "main" -r "other/repo" -b ""
# by default merges are counted so using --no-merges ensures they won't be counted
$ git-heatmap --no-merges
# filter by one or multiple authors # filter by one or multiple authors
# without an -a flag all authors will be checked # without an -a flag all authors will be checked
$ git-heatmap -a "username" -a "other" $ git-heatmap -a "username" -a "other"

View File

@ -28,6 +28,9 @@ pub struct CliArgs {
#[arg(long("until"))] #[arg(long("until"))]
pub until: Option<String>, pub until: Option<String>,
#[arg(long("no-merges"), default_value_t = false)]
pub no_merges: bool,
} }
fn get_since_date() -> String { fn get_since_date() -> String {

View File

@ -193,6 +193,13 @@ fn get_commits(args: CliArgs, start_date: NaiveDate) -> Result<(usize, Vec<Commi
.ok()? .ok()?
.to_string(); .to_string();
if args.no_merges {
let is_merge = c.parent_ids().count() > 1;
if is_merge {
return None;
}
}
let author = c.author().ok()?; let author = c.author().ok()?;
let email = author.email.to_string(); let email = author.email.to_string();