Radish alpha
r
rad:z2UcCU1LgMshWvXj6hXSDDrwB8q8M
Radicle Job Collaborative Object
Radicle
Git
cli: add timestamp to output
Fintan Halpenny committed 4 months ago
commit e37ff3447ec38823361c71910455bec5ad74035c
parent c2697d7
3 files changed +22 -2
modified Cargo.lock
@@ -277,6 +277,15 @@ dependencies = [
]

[[package]]
+
name = "chrono"
+
version = "0.4.42"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
+
dependencies = [
+
 "num-traits",
+
]
+

+
[[package]]
name = "cipher"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1364,6 +1373,7 @@ dependencies = [
name = "radicle-job"
version = "0.4.0"
dependencies = [
+
 "chrono",
 "clap",
 "indexmap",
 "nonempty 0.11.0",
modified Cargo.toml
@@ -12,6 +12,7 @@ edition = "2021"
rust-version = "1.84.0"

[dependencies]
+
chrono = { version = "0.4", default-features = false }
clap = { version = "4.5.41", features = ["derive", "wrap_help"] }
indexmap = { version = "2.7.1", features = ["serde"] }
nonempty = "0.11.0"
modified src/display.rs
@@ -3,7 +3,8 @@
//! These can be used in tools that wish to display data, such as the `rad-job`
//! CLI tool.

-
use radicle::{git::Oid, node::NodeId};
+
use chrono::Utc;
+
use radicle::{cob, git::Oid, node::NodeId};
use serde::Serialize;
use url::Url;
use uuid::Uuid;
@@ -78,6 +79,7 @@ impl Job {
                        run_id: *run_id,
                        status: *run.status(),
                        log: run.log().clone(),
+
                        timestamp: *run.timestamp(),
                    })
                    .collect();
                runs.sort_by_cached_key(|run| run.run_id);
@@ -109,7 +111,13 @@ impl Job {
        for run in self.runs.iter() {
            line(&mut s, format!("  node {}", run.node_id));
            for run2 in run.runs.iter() {
-
                line(&mut s, format!("    run {} {:?}", run2.run_id, run2.status));
+
                let date =
+
                    chrono::DateTime::<Utc>::from_timestamp_secs(run2.timestamp.as_secs() as i64)
+
                        .expect("run timestamp is out of range");
+
                line(
+
                    &mut s,
+
                    format!("    run {} {:?} [{}]", run2.run_id, run2.status, date),
+
                );
                line(&mut s, format!("      log  {}", run2.log));
            }
        }
@@ -129,4 +137,5 @@ struct Run {
    run_id: Uuid,
    status: Status,
    log: Url,
+
    timestamp: cob::Timestamp,
}