From 3e2cf83f9b3cc5753e75c44fc58d293d011e1d59 Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Thu, 4 May 2023 08:59:51 -0500 Subject: [PATCH] cli: List patches by last update To help users notice changes to patches, make `rad patch` order patches by revision timestamp instead of patch timestamp. --- radicle-cli/examples/rad-patch.md | 2 +- .../workflow/4-patching-contributor.md | 2 +- radicle-cli/src/commands/patch/list.rs | 22 +++++++++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/radicle-cli/examples/rad-patch.md b/radicle-cli/examples/rad-patch.md index 0138a3b1..f35346fe 100644 --- a/radicle-cli/examples/rad-patch.md +++ b/radicle-cli/examples/rad-patch.md @@ -42,7 +42,7 @@ It will now be listed as one of the project's open patches. ``` $ rad patch ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ -│ ● ID Title Author Head + - Opened │ +│ ● ID Title Author Head + - Updated │ ├──────────────────────────────────────────────────────────────────────────────────────────────┤ │ ● de3096d Define power requirements z6MknSL…StBU8Vi (you) 3e674d1 +0 -0 4 months ago │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ diff --git a/radicle-cli/examples/workflow/4-patching-contributor.md b/radicle-cli/examples/workflow/4-patching-contributor.md index 024a042c..d75fc9a0 100644 --- a/radicle-cli/examples/workflow/4-patching-contributor.md +++ b/radicle-cli/examples/workflow/4-patching-contributor.md @@ -42,7 +42,7 @@ It will now be listed as one of the project's open patches. ``` $ rad patch ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ -│ ● ID Title Author Head + - Opened │ +│ ● ID Title Author Head + - Updated │ ├──────────────────────────────────────────────────────────────────────────────────────────────┤ │ ● 5f0a547 Define power requirements z6Mkt67…v4N1tRk (you) 3e674d1 +0 -0 4 months ago │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ diff --git a/radicle-cli/src/commands/patch/list.rs b/radicle-cli/src/commands/patch/list.rs index 110ef59d..4a3baa3e 100644 --- a/radicle-cli/src/commands/patch/list.rs +++ b/radicle-cli/src/commands/patch/list.rs @@ -52,17 +52,20 @@ pub fn run( term::format::bold(String::from("Head")).into(), term::format::bold(String::from("+")).into(), term::format::bold(String::from("-")).into(), - term::format::bold(String::from("Opened")).into(), + term::format::bold(String::from("Updated")).into(), ]); table.divider(); let me = *profile.id(); all.sort_by(|(id1, p1), (id2, p2)| { let is_me = (p2.author().id().as_key() == &me).cmp(&(p1.author().id().as_key() == &me)); - let by_timestamp = p2.timestamp().cmp(&p1.timestamp()); let by_id = id1.cmp(id2); + let by_rev_time = p2 + .latest() + .map(|(_, r)| r.timestamp()) + .cmp(&p1.latest().map(|(_, r)| r.timestamp())); - is_me.then(by_timestamp).then(by_id) + is_me.then(by_rev_time).then(by_id) }); let mut errors = Vec::new(); @@ -118,10 +121,15 @@ pub fn row( term::format::secondary(term::format::oid(revision.head())).into(), term::format::positive(format!("+{}", stats.insertions())).into(), term::format::negative(format!("-{}", stats.deletions())).into(), - term::format::timestamp(&patch.timestamp()) - .dim() - .italic() - .into(), + term::format::timestamp( + &patch + .latest() + .map(|(_, r)| r.timestamp()) + .unwrap_or_default(), + ) + .dim() + .italic() + .into(), ]) }