Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Fix and simplify `rad review`
Alexis Sellier committed 3 years ago
commit c1face7cd82eefebb309d723e609f16538ba3992
parent f999a62da2e78f9210fe4403b76e91957b8cf646
2 files changed +7 -32
modified radicle-cli/examples/rad-patch.md
@@ -108,7 +108,7 @@ $ rad patch checkout 191a14e52
We can also add a review verdict as such:

```
-
$ rad review 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 --accept --no-confirm --no-message --no-sync
+
$ rad review 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 --accept --no-message --no-sync
✓ Patch 191a14e accepted
```

modified radicle-cli/src/commands/review.rs
@@ -29,8 +29,6 @@ Options
    -r, --revision <number>   Revision number to review, defaults to the latest
        --[no-]sync           Sync review to seed (default: sync)
    -m, --message [<string>]  Provide a comment with the review (default: prompt)
-
        --no-confirm          Don't ask for confirmation
-
        --no-message          Don't provide a comment with the review
        --help                Print help
"#,
};
@@ -52,7 +50,6 @@ pub struct Options {
    pub message: Message,
    pub sync: bool,
    pub verbose: bool,
-
    pub confirm: bool,
    pub verdict: Option<Verdict>,
}

@@ -66,7 +63,6 @@ impl Args for Options {
        let mut message = Message::default();
        let mut sync = true;
        let mut verbose = false;
-
        let mut confirm = true;
        let mut verdict = None;

        while let Some(arg) = parser.next()? {
@@ -94,9 +90,6 @@ impl Args for Options {
                        message.append(&txt);
                    }
                }
-
                Long("no-confirm") => {
-
                    confirm = false;
-
                }
                Long("no-message") => {
                    message = Message::Blank;
                }
@@ -121,7 +114,6 @@ impl Args for Options {
                id: id.ok_or_else(|| anyhow!("a patch to review must be provided"))?,
                message,
                sync,
-
                confirm,
                revision,
                verbose,
                verdict,
@@ -153,31 +145,14 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
        .nth(revision_ix)
        .ok_or_else(|| anyhow!("revision R{} does not exist", revision_ix))?;
    let message = options.message.get(REVIEW_HELP_MSG);
-

-
    let verdict_pretty = match options.verdict {
-
        Some(Verdict::Accept) => term::format::highlight("Accept"),
-
        Some(Verdict::Reject) => term::format::negative("Reject"),
-
        None => term::format::dim("Review"),
+
    let message = message.replace(REVIEW_HELP_MSG.trim(), "");
+
    let message = if message.is_empty() {
+
        None
+
    } else {
+
        Some(message)
    };
-
    if options.confirm
-
        && !term::confirm(format!(
-
            "{} {} {} by {}?",
-
            verdict_pretty,
-
            patch_id_pretty,
-
            term::format::dim(format!("R{revision_ix}")),
-
            term::format::tertiary(patch.author().id())
-
        ))
-
    {
-
        anyhow::bail!("Patch review aborted");
-
    }

-
    patch.review(
-
        *revision_id,
-
        options.verdict,
-
        Some(message),
-
        vec![],
-
        &signer,
-
    )?;
+
    patch.review(*revision_id, options.verdict, message, vec![], &signer)?;

    match options.verdict {
        Some(Verdict::Accept) => {