Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
Handle corner cases of interactively entered commit messages
Merged did:key:z6Mkgfwr...BYQp opened 2 years ago
  1. Split on double newline fails when description is empty
  2. Title must be a single line
1 file changed +7 -3 3ad2b443 f0b84465
modified radicle-cli/src/terminal/patch.rs
@@ -87,12 +87,16 @@ impl Message {
        placeholder.push_str(help);

        let output = Self::Edit.get(&placeholder)?;
-
        let Some((title, description)) = output.split_once("\n\n") else {
-
            return Ok(None);
+
        let output = match output.split_once("\n\n") {
+
            Some((x, y)) => Some((x, y)),
+
            None => Some((output.as_str(), "")),
+
        };
+
        let Some((title, description)) = output else {
+
            return Ok(None)
        };
        let (title, description) = (title.trim(), description.trim());

-
        if title.is_empty() {
+
        if title.is_empty() | title.contains('\n') {
            return Ok(None);
        }
        Ok(Some((title.to_owned(), description.to_owned())))