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]]
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",

View File

@ -2,12 +2,12 @@ cargo-features = ["codegen-backend"]
[package]
name = "git-heatmap"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
authors = ["Wynd <wyndftw@proton.me>"]
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

View File

@ -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"

View File

@ -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;
}