mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 05:50:31 +08:00
Fix patch description method
The description is not actually optional, so don't return an `Option`.
This commit is contained in:
@@ -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 {}",
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user