Skip to content

Commit 002ae3c

Browse files
authored
refactor(clippy): apply single_match_else lint (#878)
1 parent 8dca309 commit 002ae3c

File tree

2 files changed

+40
-46
lines changed

2 files changed

+40
-46
lines changed

git-cliff-core/src/commit.rs

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -425,38 +425,36 @@ impl Serialize for Commit<'_> {
425425

426426
let mut commit = serializer.serialize_struct("Commit", 9)?;
427427
commit.serialize_field("id", &self.id)?;
428-
match &self.conv {
429-
Some(conv) => {
430-
commit.serialize_field("message", conv.description())?;
431-
commit.serialize_field("body", &conv.body())?;
432-
commit.serialize_field("footers", &SerializeFooters(self))?;
433-
commit.serialize_field(
434-
"group",
435-
self.group.as_ref().unwrap_or(&conv.type_().to_string()),
436-
)?;
437-
commit.serialize_field(
438-
"breaking_description",
439-
&conv.breaking_description(),
440-
)?;
441-
commit.serialize_field("breaking", &conv.breaking())?;
442-
commit.serialize_field(
443-
"scope",
444-
&self
445-
.scope
446-
.as_deref()
447-
.or_else(|| conv.scope().map(|v| v.as_str()))
448-
.or(self.default_scope.as_deref()),
449-
)?;
450-
}
451-
None => {
452-
commit.serialize_field("message", &self.message)?;
453-
commit.serialize_field("group", &self.group)?;
454-
commit.serialize_field(
455-
"scope",
456-
&self.scope.as_deref().or(self.default_scope.as_deref()),
457-
)?;
458-
}
428+
if let Some(conv) = &self.conv {
429+
commit.serialize_field("message", conv.description())?;
430+
commit.serialize_field("body", &conv.body())?;
431+
commit.serialize_field("footers", &SerializeFooters(self))?;
432+
commit.serialize_field(
433+
"group",
434+
self.group.as_ref().unwrap_or(&conv.type_().to_string()),
435+
)?;
436+
commit.serialize_field(
437+
"breaking_description",
438+
&conv.breaking_description(),
439+
)?;
440+
commit.serialize_field("breaking", &conv.breaking())?;
441+
commit.serialize_field(
442+
"scope",
443+
&self
444+
.scope
445+
.as_deref()
446+
.or_else(|| conv.scope().map(|v| v.as_str()))
447+
.or(self.default_scope.as_deref()),
448+
)?;
449+
} else {
450+
commit.serialize_field("message", &self.message)?;
451+
commit.serialize_field("group", &self.group)?;
452+
commit.serialize_field(
453+
"scope",
454+
&self.scope.as_deref().or(self.default_scope.as_deref()),
455+
)?;
459456
}
457+
460458
commit.serialize_field("links", &self.links)?;
461459
commit.serialize_field("author", &self.author)?;
462460
commit.serialize_field("committer", &self.committer)?;

git-cliff-core/src/config.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -260,21 +260,17 @@ impl Bump {
260260
///
261261
/// This function also logs the returned value.
262262
pub fn get_initial_tag(&self) -> String {
263-
match self.initial_tag.clone() {
264-
Some(tag) => {
265-
warn!(
266-
"No releases found, using initial tag '{tag}' as the next \
267-
version."
268-
);
269-
tag
270-
}
271-
None => {
272-
warn!(
273-
"No releases found, using {DEFAULT_INITIAL_TAG} as the next \
274-
version."
275-
);
276-
DEFAULT_INITIAL_TAG.into()
277-
}
263+
if let Some(tag) = self.initial_tag.clone() {
264+
warn!(
265+
"No releases found, using initial tag '{tag}' as the next version."
266+
);
267+
tag
268+
} else {
269+
warn!(
270+
"No releases found, using {DEFAULT_INITIAL_TAG} as the next \
271+
version."
272+
);
273+
DEFAULT_INITIAL_TAG.into()
278274
}
279275
}
280276
}

0 commit comments

Comments
 (0)