1
1
mirror of https://github.com/orhun/git-cliff.git synced 2025-01-07 13:09:48 +03:00

refactor(clippy): apply clippy suggestions

This commit is contained in:
Orhun Parmaksız 2021-12-31 21:27:52 +03:00
parent b88e7d30be
commit cd018e90a1
No known key found for this signature in database
GPG Key ID: B928720AEC532117
4 changed files with 4 additions and 9 deletions

View File

@ -197,10 +197,7 @@ impl Serialize for Commit<'_> {
commit.serialize_field("breaking", &conv.breaking())?; commit.serialize_field("breaking", &conv.breaking())?;
commit.serialize_field( commit.serialize_field(
"scope", "scope",
&conv &conv.scope().map(|v| v.as_str()).or(self.scope.as_deref()),
.scope()
.map(|v| v.as_str())
.or_else(|| self.scope.as_deref()),
)?; )?;
} }
None => { None => {

View File

@ -21,7 +21,7 @@ impl EmbeddedConfig {
/// Extracts the embedded content. /// Extracts the embedded content.
pub fn get_config() -> Result<String> { pub fn get_config() -> Result<String> {
match Self::get(crate::DEFAULT_CONFIG) { match Self::get(crate::DEFAULT_CONFIG) {
Some(v) => Ok(str::from_utf8(&v.data.into_owned())?.to_string()), Some(v) => Ok(str::from_utf8(&v.data)?.to_string()),
None => Err(Error::EmbeddedError(String::from( None => Err(Error::EmbeddedError(String::from(
"Embedded config not found", "Embedded config not found",
))), ))),

View File

@ -119,8 +119,7 @@ impl Repository {
if let Some(commit) = tag if let Some(commit) = tag
.target() .target()
.ok() .ok()
.map(|target| target.into_commit().ok()) .and_then(|target| target.into_commit().ok())
.flatten()
{ {
tags.push((commit, name)); tags.push((commit, name));
} }

View File

@ -56,8 +56,7 @@ pub fn run(mut args: Opt) -> Result<()> {
}?; }?;
if let Some(config_path) = dirs_next::config_dir() if let Some(config_path) = dirs_next::config_dir()
.map(|dir| dir.join(env!("CARGO_PKG_NAME")).join(DEFAULT_CONFIG)) .map(|dir| dir.join(env!("CARGO_PKG_NAME")).join(DEFAULT_CONFIG))
.map(|path| path.to_str().map(String::from)) .and_then(|path| path.to_str().map(String::from))
.flatten()
{ {
if fs::metadata(&config_path).is_ok() { if fs::metadata(&config_path).is_ok() {
path = config_path; path = config_path;