Print commit time
This commit is contained in:
parent
f18537080a
commit
4001dd9328
3 changed files with 8 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -655,6 +655,7 @@ dependencies = [
|
||||||
"git-repository",
|
"git-repository",
|
||||||
"terminal_size",
|
"terminal_size",
|
||||||
"textplots",
|
"textplots",
|
||||||
|
"time",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,4 @@ clap = { version = "4.1.1", features = ["derive", "deprecated"] }
|
||||||
git-repository = "0.33.0"
|
git-repository = "0.33.0"
|
||||||
terminal_size = "0.2.3"
|
terminal_size = "0.2.3"
|
||||||
textplots = "0.8.0"
|
textplots = "0.8.0"
|
||||||
|
time = "0.3.17"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ use git_repository::{
|
||||||
};
|
};
|
||||||
use terminal_size::{Height, Width};
|
use terminal_size::{Height, Width};
|
||||||
use textplots::{Chart, Plot, Shape};
|
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)]
|
#[derive(Debug, Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
|
@ -63,8 +67,9 @@ fn main() -> anyhow::Result<()> {
|
||||||
let mut line_cache = HashMap::new();
|
let mut line_cache = HashMap::new();
|
||||||
for ancestor in commit.ancestors().all()? {
|
for ancestor in commit.ancestors().all()? {
|
||||||
let ancestor = repo.find_object(ancestor.unwrap())?.try_into_commit()?;
|
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)?;
|
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);
|
lines.push(line_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue