From a6782ac2d67062729861ae7bad06d0d5c946e3a2 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Tue, 13 Jun 2023 11:47:54 +0200 Subject: [PATCH] cli: Add `-v` flag to `rad patch show` With this flag, additional data such as the patch base is shown. --- radicle-cli/examples/rad-patch-ahead-behind.md | 6 ++++-- radicle-cli/src/commands/patch.rs | 11 +++++++++-- radicle-cli/src/commands/patch/show.rs | 7 +++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/radicle-cli/examples/rad-patch-ahead-behind.md b/radicle-cli/examples/rad-patch-ahead-behind.md index 8eb496f0..87b6f534 100644 --- a/radicle-cli/examples/rad-patch-ahead-behind.md +++ b/radicle-cli/examples/rad-patch-ahead-behind.md @@ -55,12 +55,13 @@ $ rad patch list When showing the patch, we see that it is `ahead 1, behind 1`, since master has diverged by one commit: ``` -$ rad patch show -p 866f59c +$ rad patch show -v -p 866f59c ╭────────────────────────────────────────────────────────────────────╮ │ Title Add Alan │ │ Patch 866f59c001cd4d78a151f444b34265566c83c264 │ │ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi │ │ Head 5c88a79d75f5c2b4cc51ee6f163d2db91ee198d7 │ +│ Base f64fb2c8fe28f7c458c72ec8d700373924794943 │ │ Branches feature/1 │ │ Commits ahead 1, behind 1 │ │ Status open │ @@ -100,12 +101,13 @@ To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkE When we look at the patch, we see that it has both commits, because this new patch uses the same base as the previous patch: ``` -$ rad patch show 57cb9b2758518e547de324456ac967fda456c6c1 +$ rad patch show -v 57cb9b2758518e547de324456ac967fda456c6c1 ╭────────────────────────────────────────────────────────────────────╮ │ Title Add Mel │ │ Patch 57cb9b2758518e547de324456ac967fda456c6c1 │ │ Author did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi │ │ Head 7f63fcbcf23fc39eea784c091ad3d20d7e4bd005 │ +│ Base f64fb2c8fe28f7c458c72ec8d700373924794943 │ │ Branches feature/2 │ │ Commits ahead 2, behind 1 │ │ Status open │ diff --git a/radicle-cli/src/commands/patch.rs b/radicle-cli/src/commands/patch.rs index 74fc1536..1cad6b37 100644 --- a/radicle-cli/src/commands/patch.rs +++ b/radicle-cli/src/commands/patch.rs @@ -55,6 +55,7 @@ Usage Show options -p, --patch Show the actual patch diff + -v, --verbose Show additional information about the patch Edit options @@ -126,6 +127,7 @@ pub enum Operation { Show { patch_id: Rev, diff: bool, + verbose: bool, }, Update { patch_id: Option, @@ -296,6 +298,7 @@ impl Args for Options { OperationName::List => Operation::List { filter }, OperationName::Show => Operation::Show { patch_id: patch_id.ok_or_else(|| anyhow!("a patch must be provided"))?, + verbose, diff, }, OperationName::Delete => Operation::Delete { @@ -355,9 +358,13 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { Operation::List { filter: Filter(f) } => { list::run(f, &repository, &profile)?; } - Operation::Show { patch_id, diff } => { + Operation::Show { + patch_id, + diff, + verbose, + } => { let patch_id = patch_id.resolve(&repository.backend)?; - show::run(&patch_id, diff, &profile, &repository, &workdir)?; + show::run(&patch_id, diff, verbose, &profile, &repository, &workdir)?; } Operation::Update { ref patch_id, diff --git a/radicle-cli/src/commands/patch/show.rs b/radicle-cli/src/commands/patch/show.rs index 11c1b01b..c3e3a0ce 100644 --- a/radicle-cli/src/commands/patch/show.rs +++ b/radicle-cli/src/commands/patch/show.rs @@ -54,6 +54,7 @@ fn patch_commits(patch: &patch::Patch, stored: &Repository) -> anyhow::Result