From 498da296fd6f2cb89419e4aecfec845ec79032b1 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 10 Jan 2024 14:00:49 +0000 Subject: [PATCH] cli: show head on patch opened MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the head of the opened patch would not be displayed, and so the user could not tell what it was if any updates were applied. Show the head for the opened revision. The below shows the difference between before and after, respectively: ``` ├─────────────────────────────────────────────────────────────────────┤ │ ● opened by z6MknSL…StBU8Vi (you) now │ │ ↑ updated to 8d6692ce2b2219a54d09ccd5feefedb2bae33eba (02bef3f) now │ │ ↑ updated to 8438ab3940316abe65c93982a0a8f39688400359 (9304dbc) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` ``` ├─────────────────────────────────────────────────────────────────────┤ │ ● opened by z6MknSL…StBU8Vi (you) (8b0ea80) now │ │ ↑ updated to 8d6692ce2b2219a54d09ccd5feefedb2bae33eba (02bef3f) now │ │ ↑ updated to 8438ab3940316abe65c93982a0a8f39688400359 (9304dbc) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/examples/rad-merge-via-push.md | 2 +- radicle-cli/examples/rad-patch-ahead-behind.md | 6 +++--- radicle-cli/examples/rad-patch-change-base.md | 4 ++-- radicle-cli/examples/rad-patch-checkout-revision.md | 2 +- radicle-cli/examples/rad-patch-draft.md | 6 +++--- radicle-cli/examples/rad-patch-edit.md | 6 +++--- radicle-cli/examples/rad-patch-pull-update.md | 2 +- radicle-cli/examples/rad-patch-update.md | 4 ++-- radicle-cli/examples/rad-patch-via-push.md | 6 +++--- radicle-cli/examples/rad-patch.md | 8 ++++---- radicle-cli/examples/workflow/4-patching-contributor.md | 2 +- radicle-cli/examples/workflow/5-patching-maintainer.md | 4 ++-- radicle-cli/src/commands/patch/list.rs | 8 +++++++- 13 files changed, 33 insertions(+), 27 deletions(-) diff --git a/radicle-cli/examples/rad-merge-via-push.md b/radicle-cli/examples/rad-merge-via-push.md index e50924ce..79c12c29 100644 --- a/radicle-cli/examples/rad-merge-via-push.md +++ b/radicle-cli/examples/rad-merge-via-push.md @@ -87,7 +87,7 @@ $ rad patch show 8357a9f1d61e80309d314491aa754969d9f47d77 ├────────────────────────────────────────────────────────────────┤ │ daf349f Second change │ ├────────────────────────────────────────────────────────────────┤ -│ ● opened by alice (you) now │ +│ ● opened by alice (you) (daf349f) now │ │ └─ ✓ merged by alice (you) at revision 8357a9f (d6399c7) now │ ╰────────────────────────────────────────────────────────────────╯ ``` diff --git a/radicle-cli/examples/rad-patch-ahead-behind.md b/radicle-cli/examples/rad-patch-ahead-behind.md index c69e6007..1044ce16 100644 --- a/radicle-cli/examples/rad-patch-ahead-behind.md +++ b/radicle-cli/examples/rad-patch-ahead-behind.md @@ -68,7 +68,7 @@ $ rad patch show -v -p f03f6ea ├────────────────────────────────────────────────────┤ │ 5c88a79 Add Alan │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (5c88a79) now │ ╰────────────────────────────────────────────────────╯ commit 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7 @@ -115,7 +115,7 @@ $ rad patch show -v 13a3d64f00e1c3f01c4d65fe115d2a2ed57d6cb7 │ 7f63fcb Add Mel │ │ 5c88a79 Add Alan │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (7f63fcb) now │ ╰────────────────────────────────────────────────────╯ ``` @@ -149,6 +149,6 @@ $ rad patch show -v c0083bdc7f7acda2e7a9db3134566dd385c7e88e ├────────────────────────────────────────────────────┤ │ 7f63fcb Add Mel │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (7f63fcb) now │ ╰────────────────────────────────────────────────────╯ ``` diff --git a/radicle-cli/examples/rad-patch-change-base.md b/radicle-cli/examples/rad-patch-change-base.md index b2e68c1c..54d540ee 100644 --- a/radicle-cli/examples/rad-patch-change-base.md +++ b/radicle-cli/examples/rad-patch-change-base.md @@ -57,7 +57,7 @@ $ rad patch show 11188b8 -v │ 27857ec Add README, just for the fun │ │ 3e674d1 Define power requirements │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (27857ec) now │ ╰────────────────────────────────────────────────────╯ ``` @@ -87,7 +87,7 @@ $ rad patch show 11188b8 -v ├─────────────────────────────────────────────────────────────────────┤ │ 27857ec Add README, just for the fun │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (27857ec) now │ │ ↑ updated to ea90a38b4df0b323149a06b0472ea1cf9a754dca (27857ec) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` diff --git a/radicle-cli/examples/rad-patch-checkout-revision.md b/radicle-cli/examples/rad-patch-checkout-revision.md index 583b948e..9101e4e9 100644 --- a/radicle-cli/examples/rad-patch-checkout-revision.md +++ b/radicle-cli/examples/rad-patch-checkout-revision.md @@ -30,7 +30,7 @@ $ rad patch show 6ff4f09 │ 27857ec Add README, just for the fun │ │ 3e674d1 Define power requirements │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (3e674d1) now │ │ ↑ updated to 0c0942e2ff2488617d950ede15567ca39a29972e (27857ec) now │ │ ↑ updated to 2bf48de79e371014f084b5501ecc9c9c4182e7fc (639f44a) now │ ╰─────────────────────────────────────────────────────────────────────╯ diff --git a/radicle-cli/examples/rad-patch-draft.md b/radicle-cli/examples/rad-patch-draft.md index 34825114..f4f937c9 100644 --- a/radicle-cli/examples/rad-patch-draft.md +++ b/radicle-cli/examples/rad-patch-draft.md @@ -29,7 +29,7 @@ $ rad patch show 193a2540ded82245b49971de8afc89a129502c6d ├────────────────────────────────────────────────────┤ │ 2a46583 Nothing to see here.. │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │ +│ ● opened by z6MknSL…StBU8Vi (you) (2a46583) [ .. ] │ ╰────────────────────────────────────────────────────╯ ``` @@ -52,7 +52,7 @@ $ rad patch show 193a2540ded82245b49971de8afc89a129502c6d ├────────────────────────────────────────────────────┤ │ 2a46583 Nothing to see here.. │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │ +│ ● opened by z6MknSL…StBU8Vi (you) (2a46583) [ .. ] │ ╰────────────────────────────────────────────────────╯ ``` @@ -73,6 +73,6 @@ $ rad patch show 193a2540ded82245b49971de8afc89a129502c6d ├────────────────────────────────────────────────────┤ │ 2a46583 Nothing to see here.. │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) [ ... ] │ +│ ● opened by z6MknSL…StBU8Vi (you) (2a46583) [ .. ] │ ╰────────────────────────────────────────────────────╯ ``` diff --git a/radicle-cli/examples/rad-patch-edit.md b/radicle-cli/examples/rad-patch-edit.md index e1b99be7..0779982d 100644 --- a/radicle-cli/examples/rad-patch-edit.md +++ b/radicle-cli/examples/rad-patch-edit.md @@ -53,7 +53,7 @@ $ rad patch show 0631b2d │ 8945f61 Define the LICENSE │ │ 03c02af Add README, just for the fun │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (03c02af) now │ │ ↑ updated to bbc91fd4c74bfbbb162ec4b97cd8cefe623814d7 (8945f61) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` @@ -78,7 +78,7 @@ $ rad patch show 0631b2d │ 8945f61 Define the LICENSE │ │ 03c02af Add README, just for the fun │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (03c02af) now │ │ ↑ updated to bbc91fd4c74bfbbb162ec4b97cd8cefe623814d7 (8945f61) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` @@ -106,7 +106,7 @@ $ rad patch show 0631b2d │ 8945f61 Define the LICENSE │ │ 03c02af Add README, just for the fun │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (03c02af) now │ │ ↑ updated to bbc91fd4c74bfbbb162ec4b97cd8cefe623814d7 (8945f61) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` diff --git a/radicle-cli/examples/rad-patch-pull-update.md b/radicle-cli/examples/rad-patch-pull-update.md index 473cfb55..aed3c520 100644 --- a/radicle-cli/examples/rad-patch-pull-update.md +++ b/radicle-cli/examples/rad-patch-pull-update.md @@ -103,7 +103,7 @@ $ rad patch show 48c3035 │ cad2666 Bob's commit #2 │ │ bdcdb30 Bob's commit #1 │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by bob z6Mkt67…v4N1tRk now │ +│ ● opened by bob z6Mkt67…v4N1tRk (bdcdb30) now │ │ ↑ updated to 8c15a61af45f561b4bf0694aee03ade34a1b18f5 (cad2666) now │ ╰─────────────────────────────────────────────────────────────────────╯ $ git ls-remote rad diff --git a/radicle-cli/examples/rad-patch-update.md b/radicle-cli/examples/rad-patch-update.md index 849d212b..8bd41baa 100644 --- a/radicle-cli/examples/rad-patch-update.md +++ b/radicle-cli/examples/rad-patch-update.md @@ -24,7 +24,7 @@ $ rad patch show 8f5dcedc07a89928fd450bce1479f2559bcfd1d4 ├────────────────────────────────────────────────────┤ │ 51b2f0f Not a real change │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (51b2f0f) now │ ╰────────────────────────────────────────────────────╯ ``` @@ -66,7 +66,7 @@ $ rad patch show 8f5dcedc07a89928fd450bce1479f2559bcfd1d4 │ 4d27214 Rename readme file │ │ 51b2f0f Not a real change │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (51b2f0f) now │ │ ↑ updated to 74d453f93d81bb535ffa4ef65c46e5bd0a76015d (4d27214) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` diff --git a/radicle-cli/examples/rad-patch-via-push.md b/radicle-cli/examples/rad-patch-via-push.md index bd7affdd..7969081b 100644 --- a/radicle-cli/examples/rad-patch-via-push.md +++ b/radicle-cli/examples/rad-patch-via-push.md @@ -33,7 +33,7 @@ $ rad patch show 82faae29b2a2f11bf45bbba4c4787d6b32a12447 ├────────────────────────────────────────────────────┤ │ 42d894a Add things │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (42d894a) now │ ╰────────────────────────────────────────────────────╯ ``` @@ -145,7 +145,7 @@ $ rad patch show b77b2e8 │ 02bef3f Improve code │ │ 8b0ea80 Add more things │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (8b0ea80) now │ │ ↑ updated to 8d6692ce2b2219a54d09ccd5feefedb2bae33eba (02bef3f) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` @@ -221,7 +221,7 @@ $ rad patch show b77b2e8 │ 9304dbc Amended commit │ │ 8b0ea80 Add more things │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (8b0ea80) now │ │ ↑ updated to 8d6692ce2b2219a54d09ccd5feefedb2bae33eba (02bef3f) now │ │ ↑ updated to 8438ab3940316abe65c93982a0a8f39688400359 (9304dbc) now │ ╰─────────────────────────────────────────────────────────────────────╯ diff --git a/radicle-cli/examples/rad-patch.md b/radicle-cli/examples/rad-patch.md index 13754a4c..1c7382a2 100644 --- a/radicle-cli/examples/rad-patch.md +++ b/radicle-cli/examples/rad-patch.md @@ -56,7 +56,7 @@ $ rad patch show 6ff4f09c1b5a81347981f59b02ef43a31a07cdae -p ├────────────────────────────────────────────────────┤ │ 3e674d1 Define power requirements │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (3e674d1) now │ ╰────────────────────────────────────────────────────╯ commit 3e674d1a1df90807e934f9ae5da2591dd6848a33 @@ -110,7 +110,7 @@ $ rad patch show 6ff4f09 ├────────────────────────────────────────────────────┤ │ 3e674d1 Define power requirements │ ├────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (3e674d1) now │ ╰────────────────────────────────────────────────────╯ ``` @@ -177,7 +177,7 @@ $ rad patch show 6ff4f09 │ 27857ec Add README, just for the fun │ │ 3e674d1 Define power requirements │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (3e674d1) now │ │ ↑ updated to e0fd9f00b51e10e1ca88868e68e46e859ed371d7 (27857ec) now │ │ └─ ✓ accepted by z6MknSL…StBU8Vi (you) now │ ╰─────────────────────────────────────────────────────────────────────╯ @@ -203,7 +203,7 @@ $ rad patch show 6ff4f09 │ 27857ec Add README, just for the fun │ │ 3e674d1 Define power requirements │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by z6MknSL…StBU8Vi (you) now │ +│ ● opened by z6MknSL…StBU8Vi (you) (3e674d1) now │ │ ↑ updated to e0fd9f00b51e10e1ca88868e68e46e859ed371d7 (27857ec) now │ │ └─ ✓ accepted by z6MknSL…StBU8Vi (you) now │ ╰─────────────────────────────────────────────────────────────────────╯ diff --git a/radicle-cli/examples/workflow/4-patching-contributor.md b/radicle-cli/examples/workflow/4-patching-contributor.md index e1e32624..a2dcd6b4 100644 --- a/radicle-cli/examples/workflow/4-patching-contributor.md +++ b/radicle-cli/examples/workflow/4-patching-contributor.md @@ -54,7 +54,7 @@ $ rad patch show 3581e83ad18f5cdd806ab50fa11cfd5dd4e8ae1c ├────────────────────────────────────────────────────┤ │ 3e674d1 Define power requirements │ ├────────────────────────────────────────────────────┤ -│ ● opened by bob (you) now │ +│ ● opened by bob (you) (3e674d1) now │ ╰────────────────────────────────────────────────────╯ ``` diff --git a/radicle-cli/examples/workflow/5-patching-maintainer.md b/radicle-cli/examples/workflow/5-patching-maintainer.md index 46ffe478..4f985677 100644 --- a/radicle-cli/examples/workflow/5-patching-maintainer.md +++ b/radicle-cli/examples/workflow/5-patching-maintainer.md @@ -33,7 +33,7 @@ $ rad patch show 3581e83 │ 27857ec Add README, just for the fun │ │ 3e674d1 Define power requirements │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by bob z6Mkt67…v4N1tRk now │ +│ ● opened by bob z6Mkt67…v4N1tRk (3e674d1) now │ │ ↑ updated to 6de8527cdf51f96e12649c7278efe1dccfdee885 (27857ec) now │ ╰─────────────────────────────────────────────────────────────────────╯ ``` @@ -103,7 +103,7 @@ $ rad patch show 3581e83 │ 27857ec Add README, just for the fun │ │ 3e674d1 Define power requirements │ ├─────────────────────────────────────────────────────────────────────┤ -│ ● opened by bob z6Mkt67…v4N1tRk now │ +│ ● opened by bob z6Mkt67…v4N1tRk (3e674d1) now │ │ ↑ updated to 6de8527cdf51f96e12649c7278efe1dccfdee885 (27857ec) now │ │ * revised by alice (you) in abb0360 (f567f69) now │ │ └─ ✓ accepted by alice (you) now │ diff --git a/radicle-cli/src/commands/patch/list.rs b/radicle-cli/src/commands/patch/list.rs index e7b4bbea..b8891d23 100644 --- a/radicle-cli/src/commands/patch/list.rs +++ b/radicle-cli/src/commands/patch/list.rs @@ -183,6 +183,8 @@ struct Opened<'a> { author: Author<'a>, /// When the patch was created. timestamp: cob::Timestamp, + /// The commit head of the `Revision`. + head: git::Oid, /// Any updates performed on the root `Revision`. updates: Vec>, } @@ -216,6 +218,7 @@ impl<'a> Opened<'a> { Opened { author: Author::new(&patch.author().id, profile), timestamp: patch.timestamp(), + head: revision.head(), updates: updates.into_iter().map(|(_, up)| up).collect(), } } @@ -229,7 +232,10 @@ impl<'a> Opened<'a> { .space() .extend(self.author.line()) .space() - .extend([term::format::dim(term::format::timestamp(self.timestamp)).into()]), + .extend(term::Line::spaced([ + term::format::parens(term::format::secondary(term::format::oid(self.head))).into(), + term::format::dim(term::format::timestamp(self.timestamp)).into(), + ])), ) .chain(self.updates.into_iter().map(|up| { term::Line::spaced([term::Label::space(), term::Label::from("└─ ")])