feat: add fetched-at timestamp to markdown header and json meta
This commit is contained in:
+3
-1
@@ -1,6 +1,7 @@
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
use chrono::Utc;
|
||||
use clap::Parser;
|
||||
|
||||
pub mod cli;
|
||||
@@ -35,7 +36,8 @@ pub fn run() -> anyhow::Result<()> {
|
||||
|
||||
let client = GiteaClient::new(base_url, token);
|
||||
let bundle = client.fetch_pr_bundle(&repo, args.pr_index)?;
|
||||
let doc = normalize_bundle(&repo, bundle);
|
||||
let fetched_at = Utc::now().to_rfc3339();
|
||||
let doc = normalize_bundle(&repo, fetched_at, bundle);
|
||||
|
||||
let rendered = match args.format {
|
||||
OutputFormat::Markdown => render_markdown(&doc),
|
||||
|
||||
@@ -15,6 +15,7 @@ pub struct PrMeta {
|
||||
pub pr_index: i64,
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub fetched_at: Option<String>,
|
||||
pub state: String,
|
||||
pub author: String,
|
||||
pub base_branch: String,
|
||||
|
||||
+2
-1
@@ -9,7 +9,7 @@ use crate::model::{
|
||||
ReviewItem,
|
||||
};
|
||||
|
||||
pub fn normalize_bundle(repo: &str, bundle: PullBundleDto) -> PrReviewDocument {
|
||||
pub fn normalize_bundle(repo: &str, fetched_at: String, bundle: PullBundleDto) -> PrReviewDocument {
|
||||
let PullBundleDto {
|
||||
pull,
|
||||
reviews,
|
||||
@@ -33,6 +33,7 @@ pub fn normalize_bundle(repo: &str, bundle: PullBundleDto) -> PrReviewDocument {
|
||||
pr_index: pull.number,
|
||||
title: pull.title,
|
||||
description: pull.body,
|
||||
fetched_at: Some(fetched_at),
|
||||
state: pull.state,
|
||||
author: pull.user.login,
|
||||
base_branch: pull.base.ref_name,
|
||||
|
||||
@@ -65,6 +65,8 @@ pub fn render_markdown(doc: &PrReviewDocument) -> String {
|
||||
out.push_str(
|
||||
"> 编号规则:Review `<pr>.<review>`;Comment `<pr>.<review>.<comment>`;Reply `<pr>.<review>.<comment>.<reply>`\n\n",
|
||||
);
|
||||
let fetched_at = doc.meta.fetched_at.as_deref().unwrap_or("unknown");
|
||||
out.push_str(&format!("> fetched at: {fetched_at}\n\n"));
|
||||
let pr_description = doc
|
||||
.meta
|
||||
.description
|
||||
|
||||
Reference in New Issue
Block a user