Print commit time

This commit is contained in:
Joscha 2023-01-23 13:48:57 +01:00
parent f18537080a
commit 4001dd9328
3 changed files with 8 additions and 1 deletions

1
Cargo.lock generated
View file

@ -655,6 +655,7 @@ dependencies = [
"git-repository",
"terminal_size",
"textplots",
"time",
]
[[package]]

View file

@ -9,3 +9,4 @@ clap = { version = "4.1.1", features = ["derive", "deprecated"] }
git-repository = "0.33.0"
terminal_size = "0.2.3"
textplots = "0.8.0"
time = "0.3.17"

View file

@ -9,6 +9,10 @@ use git_repository::{
};
use terminal_size::{Height, Width};
use textplots::{Chart, Plot, Shape};
use time::{format_description::FormatItem, macros::format_description};
const TIME_FORMAT: &[FormatItem<'_>] =
format_description!("[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour sign:mandatory]:[offset_minute]:[offset_second]");
#[derive(Debug, Parser)]
struct Args {
@ -63,8 +67,9 @@ fn main() -> anyhow::Result<()> {
let mut line_cache = HashMap::new();
for ancestor in commit.ancestors().all()? {
let ancestor = repo.find_object(ancestor.unwrap())?.try_into_commit()?;
let time = ancestor.time()?.format(TIME_FORMAT);
let line_count = count_lines(&repo, &ancestor, &mut line_cache)?;
println!("{} {line_count}", ancestor.id);
println!("{} {time} - {line_count}", ancestor.id);
lines.push(line_count);
}