chore: fix clippy warnings
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
bc3e091f45
commit
2d5abedf1a
@ -135,24 +135,18 @@ impl ChangeLog<'_> {
|
|||||||
.context("cannot convert bytes to string (contains non utf-8 char indices)")
|
.context("cannot convert bytes to string (contains non utf-8 char indices)")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_config<'a>(&self) -> Config {
|
fn default_config(&self) -> Config {
|
||||||
let config = Config {
|
let config = Config {
|
||||||
changelog: default_changelog_config(
|
changelog: default_changelog_config(None, self.release_link.as_deref()),
|
||||||
None,
|
|
||||||
self.release_link.as_deref(),
|
|
||||||
),
|
|
||||||
git: default_git_config(),
|
git: default_git_config(),
|
||||||
};
|
};
|
||||||
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_config_with_header<'a>(&self, header: Option<String>) -> Config {
|
fn default_config_with_header(&self, header: Option<String>) -> Config {
|
||||||
let config = Config {
|
let config = Config {
|
||||||
changelog: default_changelog_config(
|
changelog: default_changelog_config(header, self.release_link.as_deref()),
|
||||||
header,
|
|
||||||
self.release_link.as_deref(),
|
|
||||||
),
|
|
||||||
git: default_git_config(),
|
git: default_git_config(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -219,9 +213,9 @@ fn default_changelog_config(header: Option<String>, release_link: Option<&str>)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn default_changelog_body_config(release_link: Option<&str>) -> String {
|
fn default_changelog_body_config(release_link: Option<&str>) -> String {
|
||||||
const pre: &str = r#"
|
const PRE: &str = r#"
|
||||||
## [{{ version | trim_start_matches(pat="v") }}]"#;
|
## [{{ version | trim_start_matches(pat="v") }}]"#;
|
||||||
const post: &str = r#" - {{ timestamp | date(format="%Y-%m-%d") }}
|
const POST: &str = r#" - {{ timestamp | date(format="%Y-%m-%d") }}
|
||||||
{% for group, commits in commits | group_by(attribute="group") %}
|
{% for group, commits in commits | group_by(attribute="group") %}
|
||||||
### {{ group | upper_first }}
|
### {{ group | upper_first }}
|
||||||
{% for commit in commits %}
|
{% for commit in commits %}
|
||||||
@ -234,8 +228,8 @@ fn default_changelog_body_config(release_link: Option<&str>) -> String {
|
|||||||
{% endfor %}"#;
|
{% endfor %}"#;
|
||||||
|
|
||||||
match release_link {
|
match release_link {
|
||||||
Some(link) => format!("{}{}{}", pre, link, post),
|
Some(link) => format!("{}{}{}", PRE, link, POST),
|
||||||
None => format!("{}{}", pre, post),
|
None => format!("{}{}", PRE, POST),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ use crate::{
|
|||||||
versioning::{next_version::NextVersion, semver::get_most_significant_version},
|
versioning::{next_version::NextVersion, semver::get_most_significant_version},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type StdinFn = Option<Arc<Mutex<dyn Fn() -> anyhow::Result<String> + Send + Sync + 'static>>>;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
pub struct Command {
|
pub struct Command {
|
||||||
@ -32,7 +34,7 @@ pub struct Command {
|
|||||||
ui: DynUi,
|
ui: DynUi,
|
||||||
|
|
||||||
#[clap(skip)]
|
#[clap(skip)]
|
||||||
stdin: Option<Arc<Mutex<dyn Fn() -> anyhow::Result<String> + Send + Sync + 'static>>>,
|
stdin: StdinFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args)]
|
#[derive(Args)]
|
||||||
@ -96,6 +98,12 @@ config-stdin will consume stdin until the channel is closed via. EOF"
|
|||||||
config_stdin: bool,
|
config_stdin: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Command {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Command {
|
impl Command {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let args = std::env::args();
|
let args = std::env::args();
|
||||||
@ -256,10 +264,8 @@ impl Command {
|
|||||||
self.ui.write_str_ln(&format!("OK: {}", stdout));
|
self.ui.write_str_ln(&format!("OK: {}", stdout));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.ui.write_str_ln(&format!(
|
self.ui
|
||||||
"WARNING: git is not installed: {}",
|
.write_str_ln(&format!("WARNING: git is not installed: {}", e));
|
||||||
e
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,7 +401,7 @@ impl Command {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_git(&self, current_dir: &PathBuf) -> anyhow::Result<VcsClient> {
|
fn get_git(&self, current_dir: &Path) -> anyhow::Result<VcsClient> {
|
||||||
if self.global.no_vcs {
|
if self.global.no_vcs {
|
||||||
Ok(VcsClient::new_noop())
|
Ok(VcsClient::new_noop())
|
||||||
} else {
|
} else {
|
||||||
@ -490,8 +496,7 @@ pub struct PleaseSettingsConfig {
|
|||||||
pub api_url: Option<String>,
|
pub api_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
#[derive(Default)]
|
|
||||||
pub struct PleaseConfig {
|
pub struct PleaseConfig {
|
||||||
pub project: Option<PleaseProjectConfig>,
|
pub project: Option<PleaseProjectConfig>,
|
||||||
pub settings: Option<PleaseSettingsConfig>,
|
pub settings: Option<PleaseSettingsConfig>,
|
||||||
@ -507,8 +512,6 @@ impl PleaseConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
struct CuddleEmbeddedPleaseConfig {
|
struct CuddleEmbeddedPleaseConfig {
|
||||||
please: PleaseConfig,
|
please: PleaseConfig,
|
||||||
@ -558,7 +561,7 @@ fn get_config(current_dir: &Path, stdin: Option<String>) -> anyhow::Result<Pleas
|
|||||||
Ok(please_config)
|
Ok(please_config)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_config_from_file<'d, T>(current_cuddle_path: PathBuf) -> Option<PleaseConfig>
|
fn get_config_from_file<T>(current_cuddle_path: PathBuf) -> Option<PleaseConfig>
|
||||||
where
|
where
|
||||||
T: DeserializeOwned,
|
T: DeserializeOwned,
|
||||||
T: Into<PleaseConfig>,
|
T: Into<PleaseConfig>,
|
||||||
|
Loading…
Reference in New Issue
Block a user