From 64708954ca5e3d561693e44d61169f14a16d09ba Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 8 Jun 2023 16:39:50 +0200 Subject: [PATCH] cli: Remove redundant newline in patch message There was an extra newline in the patch creation message due to not accounting for commit messages with newlines at the end. This is fixed and the tests are updated to be more realistic. --- radicle-cli/src/terminal/patch.rs | 40 +++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/radicle-cli/src/terminal/patch.rs b/radicle-cli/src/terminal/patch.rs index 2640687c..61a79298 100644 --- a/radicle-cli/src/terminal/patch.rs +++ b/radicle-cli/src/terminal/patch.rs @@ -119,11 +119,11 @@ fn message_from_commits(name: &str, commits: Vec) -> Result")?; writeln!(&mut msg)?; - writeln!(&mut msg, "{commit_msg}")?; + writeln!(&mut msg, "{}", commit_msg.trim_end())?; writeln!(&mut msg)?; for (i, commit) in commits.enumerate() { - let commit_msg = commit.message().ok_or(Error::InvalidUtf8)?; + let commit_msg = commit.message().ok_or(Error::InvalidUtf8)?.trim_end(); let commit_num = i + 2; writeln!(&mut msg, "\n\ \n\ - commit 1\n\ + Commit 1\n\ + \n\ + Description\n\ \n\ \n\ \n\ - commit 2\n\ + Commit 2\n\ + \n\ + Description\n\ \n\