Small fix for start dates and updated the README and Cargo.toml files

master
Wynd 2024-09-08 00:09:12 +03:00
parent 6c474164fd
commit eaf956ef9f
4 changed files with 18 additions and 15 deletions

6
Cargo.lock generated
View File

@ -102,9 +102,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.86" version = "1.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8"
[[package]] [[package]]
name = "arc-swap" name = "arc-swap"
@ -426,7 +426,7 @@ dependencies = [
[[package]] [[package]]
name = "git-heatmap" name = "git-heatmap"
version = "1.0.0" version = "1.0.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",

View File

@ -2,12 +2,12 @@ cargo-features = ["codegen-backend"]
[package] [package]
name = "git-heatmap" name = "git-heatmap"
version = "1.0.0" version = "1.0.1"
edition = "2021" edition = "2021"
authors = ["Wynd <wyndftw@proton.me>"] authors = ["Wynd <wyndftw@proton.me>"]
description = "A simple and customizable heatmap for git repos" description = "A simple and customizable heatmap for git repos"
readme = "README.md" readme = "README.md"
repository = "https://git.pixelatedw.xyz/wynd/git-heatmap" repository = "https://codeberg.org/WyndFTW/git-heatmap"
license = "MIT" license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,11 +1,15 @@
# git-heatmap # 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 ## Install
### Using cargo
- run the following command `cargo install git-heatmap`
### From source using cargo ### From source using cargo
- clone the repository - clone the repository
@ -35,7 +39,7 @@ $ git-heatmap -b "main"
$ git-heatmap -r "/path/to/repo" -b "main other test" $ git-heatmap -r "/path/to/repo" -b "main other test"
# supports checking different branches per repository however # 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" $ 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 # 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 # the amount of commits in that day
$ git-heatmap --counting by-amount $ 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 # without an -a flag all authors will be checked
$ git-heatmap -a "username" -a "other" $ git-heatmap -a "username" -a "other"

View File

@ -1,6 +1,4 @@
#![feature(byte_slice_trim_ascii)]
#![feature(let_chains)] #![feature(let_chains)]
#![allow(dead_code)]
use std::{ use std::{
cmp::Reverse, cmp::Reverse,
@ -10,7 +8,7 @@ use std::{
}; };
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use chrono::{DateTime, Duration, Local, NaiveDate, TimeZone}; use chrono::{DateTime, Duration, Local, NaiveDate, NaiveTime, TimeZone};
use clap::Parser; use clap::Parser;
use gix::{bstr::ByteSlice, traverse::commit::simple::Sorting, ObjectId}; use gix::{bstr::ByteSlice, traverse::commit::simple::Sorting, ObjectId};
use heatmap::{ColorLogic, HeatmapColors}; use heatmap::{ColorLogic, HeatmapColors};
@ -212,10 +210,11 @@ fn get_commits(
} }
}; };
let current_time = Local::now().time(); let midnight = NaiveTime::from_hms_opt(0, 0, 0).unwrap();
let start_date = start_date.and_time(current_time); let start_date = start_date.and_time(midnight);
let start_date = Local.from_local_datetime(&start_date).unwrap(); 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 = end_date.and_time(current_time);
let end_date = Local.from_local_datetime(&end_date).unwrap(); let end_date = Local.from_local_datetime(&end_date).unwrap();
@ -284,7 +283,7 @@ fn get_commits(
let time = c.time().ok()?; let time = c.time().ok()?;
let time = let time =
DateTime::from_timestamp_millis(time.seconds * 1000)?.with_timezone(&Local); 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; return None;
} }