From eaf956ef9f83cab1bf597cfe4da651fa7937281d Mon Sep 17 00:00:00 2001 From: Wynd Date: Sun, 8 Sep 2024 00:09:12 +0300 Subject: [PATCH] Small fix for start dates and updated the README and Cargo.toml files --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- README.md | 12 ++++++++---- src/main.rs | 11 +++++------ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3447a6..8cea0f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" [[package]] name = "arc-swap" @@ -426,7 +426,7 @@ dependencies = [ [[package]] name = "git-heatmap" -version = "1.0.0" +version = "1.0.1" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 120793c..9fb8bb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,12 +2,12 @@ cargo-features = ["codegen-backend"] [package] name = "git-heatmap" -version = "1.0.0" +version = "1.0.1" edition = "2021" authors = ["Wynd "] description = "A simple and customizable heatmap for git repos" readme = "README.md" -repository = "https://git.pixelatedw.xyz/wynd/git-heatmap" +repository = "https://codeberg.org/WyndFTW/git-heatmap" license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index 6de3319..a02df9f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # git-heatmap -simple but customizable heatmap for your **local** git repos written in Rust. +simple but customizable heatmap for your **local** git repos written in rust. -![screenshot](screenshot.png) +![screenshot](https://codeberg.org/WyndFTW/git-heatmap/raw/branch/master/screenshot.png) ## Install +### Using cargo + +- run the following command `cargo install git-heatmap` + ### From source using cargo - clone the repository @@ -35,7 +39,7 @@ $ git-heatmap -b "main" $ git-heatmap -r "/path/to/repo" -b "main other test" # supports checking different branches per repository however -# the number of -b flags needs to match the number of -p flags +# the number of -b flags needs to match the number of -r flags $ git-heatmap -r "/path/to/repo" -b "main" -r "/other/repo" -b "test" # an empty string can be passed for the -b flag so all branches get checked @@ -61,7 +65,7 @@ $ git-heatmap --split-months # the amount of commits in that day $ git-heatmap --counting by-amount -# filter by one or multiple authors +# filter by one or multiple authors (respecting the .mailmap settings) # without an -a flag all authors will be checked $ git-heatmap -a "username" -a "other" diff --git a/src/main.rs b/src/main.rs index f120239..70a7786 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ -#![feature(byte_slice_trim_ascii)] #![feature(let_chains)] -#![allow(dead_code)] use std::{ cmp::Reverse, @@ -10,7 +8,7 @@ use std::{ }; use anyhow::{anyhow, Context, Result}; -use chrono::{DateTime, Duration, Local, NaiveDate, TimeZone}; +use chrono::{DateTime, Duration, Local, NaiveDate, NaiveTime, TimeZone}; use clap::Parser; use gix::{bstr::ByteSlice, traverse::commit::simple::Sorting, ObjectId}; use heatmap::{ColorLogic, HeatmapColors}; @@ -212,10 +210,11 @@ fn get_commits( } }; - let current_time = Local::now().time(); - let start_date = start_date.and_time(current_time); + let midnight = NaiveTime::from_hms_opt(0, 0, 0).unwrap(); + let start_date = start_date.and_time(midnight); let start_date = Local.from_local_datetime(&start_date).unwrap(); + let current_time = Local::now().time(); let end_date = end_date.and_time(current_time); let end_date = Local.from_local_datetime(&end_date).unwrap(); @@ -284,7 +283,7 @@ fn get_commits( let time = c.time().ok()?; let time = DateTime::from_timestamp_millis(time.seconds * 1000)?.with_timezone(&Local); - if time <= start_date + Duration::days(1) || time > end_date { + if time < start_date || time > end_date { return None; }