Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Fix patch `description` method
Alexis Sellier committed 3 years ago
commit cf1acf7e24738f6e2833d5cd62432f18c381bf3a
parent d40f40b9af75782dad15f83b61330b3dac4ed232
3 files changed +8 -7
modified radicle-cli/src/commands/merge.rs
@@ -291,7 +291,7 @@ fn merge_commit(
    patch: &Patch,
    whoami: &PublicKey,
) -> anyhow::Result<()> {
-
    let description = patch.description().unwrap_or_default().trim();
+
    let description = patch.description().trim();
    let mut merge_opts = git::raw::MergeOptions::new();
    let mut merge_msg = format!(
        "Merge patch '{}' from {}",
modified radicle-cli/src/commands/patch/show.rs
@@ -43,8 +43,9 @@ pub fn run(
    term::info!("{}", term::format::bold(patch.title()));
    term::blank();

-
    if let Some(desc) = patch.description() {
-
        term::blob(desc.trim());
+
    let description = patch.description().trim();
+
    if !description.is_empty() {
+
        term::blob(description);
        term::blank();
    }

modified radicle/src/cob/patch.rs
@@ -188,8 +188,8 @@ impl Patch {
        self.tags.iter()
    }

-
    pub fn description(&self) -> Option<&str> {
-
        Some(self.description.get().get())
+
    pub fn description(&self) -> &str {
+
        self.description.get().get()
    }

    pub fn author(&self) -> &Author {
@@ -1091,7 +1091,7 @@ mod test {
        let patch = patches.get(&id).unwrap().unwrap();

        assert_eq!(patch.title(), "My first patch");
-
        assert_eq!(patch.description(), Some("Blah blah blah."));
+
        assert_eq!(patch.description(), "Blah blah blah.");
        assert_eq!(patch.author().id(), &author);
        assert_eq!(patch.state(), State::Proposed);
        assert_eq!(patch.target(), target);
@@ -1365,7 +1365,7 @@ mod test {
            .unwrap();

        assert_eq!(patch.clock.get(), 1);
-
        assert_eq!(patch.description(), Some("Blah blah blah."));
+
        assert_eq!(patch.description(), "Blah blah blah.");
        assert_eq!(patch.version(), 0);

        let _ = patch