Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Fix accidental issue creation
Slack Coder committed 2 years ago
commit 5d20316c57a142bafef7123e19a8889c37321673
parent 5c3f3c65f97771adcaa51d35e201d04b1773475f
1 file changed +24 -3
modified radicle-cli/src/commands/issue.rs
@@ -1,5 +1,6 @@
#![allow(clippy::or_fun_call)]
use std::ffi::OsString;
+
use std::io;
use std::str::FromStr;

use anyhow::{anyhow, Context as _};
@@ -464,7 +465,9 @@ fn prompt_issue(
        title
    };
    let description = if description.is_empty() {
-
        "Enter a description..."
+
        "<!--\n\
+
        Enter a description...\n\
+
        -->"
    } else {
        description
    };
@@ -500,10 +503,28 @@ fn prompt_issue(
        }
    }

-
    let description: String = lines.collect::<Vec<&str>>().join("\n");
-
    let meta: Metadata =
+
    let mut meta: Metadata =
        serde_yaml::from_str(&meta).context("failed to parse yaml front-matter")?;

+
    meta.title = meta.title.trim().to_string();
+
    if meta.title.is_empty() {
+
        return Err(io::Error::new(
+
            io::ErrorKind::InvalidInput,
+
            "an issue title must be provided",
+
        )
+
        .into());
+
    }
+

+
    let description: String = lines.collect::<Vec<&str>>().join("\n");
+
    let description = term::format::strip_comments(&description);
+
    if description.is_empty() {
+
        return Err(io::Error::new(
+
            io::ErrorKind::InvalidInput,
+
            "an issue description must be provided",
+
        )
+
        .into());
+
    }
+

    Ok(Some((meta, description)))
}