Show created_at date in changelog generator
This commit is contained in:
parent
40b184f022
commit
242ba99964
4 changed files with 65 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ tokio.workspace = true
|
|||
serde.workspace = true
|
||||
serde.features = ["derive"]
|
||||
|
||||
jiff = "0.2"
|
||||
webbrowser = "1"
|
||||
tracing-subscriber = "0.3"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use jiff::Timestamp;
|
||||
use serde::Deserialize;
|
||||
use tokio::fs;
|
||||
use tokio::process;
|
||||
|
|
@ -306,6 +307,7 @@ pub struct PullRequest {
|
|||
pub description: Option<String>,
|
||||
pub labels: Vec<String>,
|
||||
pub author: String,
|
||||
pub created_at: Timestamp,
|
||||
}
|
||||
|
||||
impl PullRequest {
|
||||
|
|
@ -334,6 +336,7 @@ impl PullRequest {
|
|||
body: Option<String>,
|
||||
user: User,
|
||||
labels: Vec<Label>,
|
||||
created_at: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
|
@ -354,6 +357,7 @@ impl PullRequest {
|
|||
description: schema.body,
|
||||
labels: schema.labels.into_iter().map(|label| label.name).collect(),
|
||||
author: schema.user.login,
|
||||
created_at: schema.created_at.parse()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -371,6 +375,9 @@ pub enum Error {
|
|||
|
||||
#[error("the changelog format is not valid")]
|
||||
InvalidFormat,
|
||||
|
||||
#[error("date could not be parsed: {0}")]
|
||||
InvalidDate(#[from] jiff::Error),
|
||||
}
|
||||
|
||||
impl From<io::Error> for Error {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ enum Generator {
|
|||
pending: Vec<changelog::Contribution>,
|
||||
state: State,
|
||||
preview: Vec<markdown::Item>,
|
||||
timezone: jiff::tz::TimeZone,
|
||||
},
|
||||
Done,
|
||||
}
|
||||
|
|
@ -73,6 +74,7 @@ impl Generator {
|
|||
pending,
|
||||
state: State::Loading(contribution.clone()),
|
||||
preview,
|
||||
timezone: jiff::tz::TimeZone::system(),
|
||||
};
|
||||
|
||||
Task::perform(
|
||||
|
|
@ -235,6 +237,7 @@ impl Generator {
|
|||
pending,
|
||||
state,
|
||||
preview,
|
||||
timezone,
|
||||
} => {
|
||||
let progress = {
|
||||
let total = pending.len() + changelog.len();
|
||||
|
|
@ -297,9 +300,19 @@ impl Generator {
|
|||
.spacing(10)
|
||||
.wrap();
|
||||
|
||||
let created_at = text(
|
||||
timezone
|
||||
.to_datetime(pull_request.created_at)
|
||||
.strftime("%B %d, %Y at %I:%M%p")
|
||||
.to_string(),
|
||||
)
|
||||
.size(12);
|
||||
|
||||
column![
|
||||
title,
|
||||
labels,
|
||||
row![labels, created_at]
|
||||
.align_y(Center)
|
||||
.spacing(10),
|
||||
scrollable(description)
|
||||
.spacing(10)
|
||||
.width(Fill)
|
||||
|
|
@ -370,6 +383,6 @@ impl Generator {
|
|||
}
|
||||
|
||||
fn theme(&self) -> Theme {
|
||||
Theme::TokyoNightStorm
|
||||
Theme::CatppuccinMocha
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue