Skip to content

Commit

Permalink
chore(lint): rustfmt
Browse files Browse the repository at this point in the history
Signed-off-by: Bukowa <[email protected]>
  • Loading branch information
bukowa committed Jun 15, 2024
1 parent 1499e40 commit 1e30cdb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 62 deletions.
8 changes: 4 additions & 4 deletions git-cliff-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ pub struct Bump {
/// - A major version update otherwise.
pub breaking_always_bump_major: Option<bool>,

/// Configures the initial version of the project.
///
/// When set, the version will be set to this value if no tags are found.
pub initial_tag: Option<String>,
/// Configures the initial version of the project.
///
/// When set, the version will be set to this value if no tags are found.
pub initial_tag: Option<String>,
}

/// Parser for grouping commits.
Expand Down
34 changes: 18 additions & 16 deletions git-cliff-core/src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,20 @@ impl<'a> Release<'a> {
Ok(next_version)
}
}
None => {
match config.initial_tag.clone() {
Some(tag) => {
warn!("No releases found, using initial tag '{}' as the next version.", tag);
Ok(tag)
}
None => {
warn!("No releases found, using 0.1.0 as the next version.");
Ok(String::from("0.1.0"))
}
}
}
None => match config.initial_tag.clone() {
Some(tag) => {
warn!(
"No releases found, using initial tag '{}' as the next \
version.",
tag
);
Ok(tag)
}
None => {
warn!("No releases found, using 0.1.0 as the next version.");
Ok(String::from("0.1.0"))
}
},
}
}
}
Expand Down Expand Up @@ -247,7 +249,7 @@ mod test {
release.calculate_next_version_with_config(&Bump {
features_always_bump_minor: Some(false),
breaking_always_bump_major: Some(false),
initial_tag: None,
initial_tag: None,
})?;
assert_eq!(expected_version, &next_version);
}
Expand All @@ -268,7 +270,7 @@ mod test {
release.calculate_next_version_with_config(&Bump {
features_always_bump_minor: Some(true),
breaking_always_bump_major: Some(false),
initial_tag: None,
initial_tag: None,
})?;
assert_eq!(expected_version, &next_version);
}
Expand All @@ -289,7 +291,7 @@ mod test {
release.calculate_next_version_with_config(&Bump {
features_always_bump_minor: Some(false),
breaking_always_bump_major: Some(true),
initial_tag: None,
initial_tag: None,
})?;
assert_eq!(expected_version, &next_version);
}
Expand All @@ -310,7 +312,7 @@ mod test {
empty_release.calculate_next_version_with_config(&Bump {
features_always_bump_minor: Some(features_always_bump_minor),
breaking_always_bump_major: Some(breaking_always_bump_major),
initial_tag: None,
initial_tag: None,
})?
);
}
Expand Down
73 changes: 36 additions & 37 deletions git-cliff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct Opt {
help = "Prints help information",
help_heading = "FLAGS"
)]
pub help: Option<bool>,
pub help: Option<bool>,
#[arg(
short = 'V',
long,
Expand All @@ -73,10 +73,10 @@ pub struct Opt {
help = "Prints version information",
help_heading = "FLAGS"
)]
pub version: Option<bool>,
pub version: Option<bool>,
/// Increases the logging verbosity.
#[arg(short, long, action = ArgAction::Count, alias = "debug", help_heading = Some("FLAGS"))]
pub verbose: u8,
pub verbose: u8,
/// Writes the default configuration file to cliff.toml
#[arg(
short,
Expand All @@ -85,7 +85,7 @@ pub struct Opt {
num_args = 0..=1,
required = false
)]
pub init: Option<Option<String>>,
pub init: Option<Option<String>>,
/// Sets the configuration file.
#[arg(
short,
Expand All @@ -95,7 +95,7 @@ pub struct Opt {
default_value = DEFAULT_CONFIG,
value_parser = Opt::parse_dir
)]
pub config: PathBuf,
pub config: PathBuf,
/// Sets the working directory.
#[arg(
short,
Expand All @@ -104,7 +104,7 @@ pub struct Opt {
value_name = "PATH",
value_parser = Opt::parse_dir
)]
pub workdir: Option<PathBuf>,
pub workdir: Option<PathBuf>,
/// Sets the git repository.
#[arg(
short,
Expand All @@ -114,42 +114,42 @@ pub struct Opt {
num_args(1..),
value_parser = Opt::parse_dir
)]
pub repository: Option<Vec<PathBuf>>,
pub repository: Option<Vec<PathBuf>>,
/// Sets the path to include related commits.
#[arg(
long,
env = "GIT_CLIFF_INCLUDE_PATH",
value_name = "PATTERN",
num_args(1..)
)]
pub include_path: Option<Vec<Pattern>>,
pub include_path: Option<Vec<Pattern>>,
/// Sets the path to exclude related commits.
#[arg(
long,
env = "GIT_CLIFF_EXCLUDE_PATH",
value_name = "PATTERN",
num_args(1..)
)]
pub exclude_path: Option<Vec<Pattern>>,
pub exclude_path: Option<Vec<Pattern>>,
/// Sets the regex for matching git tags.
#[arg(long, env = "GIT_CLIFF_TAG_PATTERN", value_name = "PATTERN")]
pub tag_pattern: Option<Regex>,
pub tag_pattern: Option<Regex>,
/// Sets custom commit messages to include in the changelog.
#[arg(
long,
env = "GIT_CLIFF_WITH_COMMIT",
value_name = "MSG",
num_args(1..)
)]
pub with_commit: Option<Vec<String>>,
pub with_commit: Option<Vec<String>>,
/// Sets commits that will be skipped in the changelog.
#[arg(
long,
env = "GIT_CLIFF_SKIP_COMMIT",
value_name = "SHA1",
num_args(1..)
)]
pub skip_commit: Option<Vec<String>>,
pub skip_commit: Option<Vec<String>>,
/// Prepends entries to the given changelog file.
#[arg(
short,
Expand All @@ -158,7 +158,7 @@ pub struct Opt {
value_name = "PATH",
value_parser = Opt::parse_dir
)]
pub prepend: Option<PathBuf>,
pub prepend: Option<PathBuf>,
/// Writes output to the given file.
#[arg(
short,
Expand All @@ -169,7 +169,7 @@ pub struct Opt {
num_args = 0..=1,
default_missing_value = DEFAULT_OUTPUT
)]
pub output: Option<PathBuf>,
pub output: Option<PathBuf>,
/// Sets the tag for the latest version.
#[arg(
short,
Expand All @@ -178,17 +178,16 @@ pub struct Opt {
value_name = "TAG",
allow_hyphen_values = true
)]
pub tag: Option<String>,
pub tag: Option<String>,
/// Bumps the version for unreleased changes.
#[arg(long, help_heading = Some("FLAGS"))]
pub bump: bool,
/// Sets the initial tag (version) to be set if no tag is found.
#[arg(long,
env = "GIT_CLIFF_BUMP_INITIAL_TAG", value_name = "TAG")]
pub bump_initial_tag: Option<String>,
pub bump: bool,
/// Sets the initial tag (version) to be set if no tag is found.
#[arg(long, env = "GIT_CLIFF_BUMP_INITIAL_TAG", value_name = "TAG")]
pub bump_initial_tag: Option<String>,
/// Prints bumped version for unreleased changes.
#[arg(long, help_heading = Some("FLAGS"))]
pub bumped_version: bool,
pub bumped_version: bool,
/// Sets the template for the changelog body.
#[arg(
short,
Expand All @@ -197,38 +196,38 @@ pub struct Opt {
value_name = "TEMPLATE",
allow_hyphen_values = true
)]
pub body: Option<String>,
pub body: Option<String>,
/// Processes the commits starting from the latest tag.
#[arg(short, long, help_heading = Some("FLAGS"))]
pub latest: bool,
pub latest: bool,
/// Processes the commits that belong to the current tag.
#[arg(long, help_heading = Some("FLAGS"))]
pub current: bool,
pub current: bool,
/// Processes the commits that do not belong to a tag.
#[arg(short, long, help_heading = Some("FLAGS"))]
pub unreleased: bool,
pub unreleased: bool,
/// Sorts the tags topologically.
#[arg(long, help_heading = Some("FLAGS"))]
pub topo_order: bool,
pub topo_order: bool,
/// Disables the external command execution.
#[arg(long, help_heading = Some("FLAGS"))]
pub no_exec: bool,
pub no_exec: bool,
/// Prints changelog context as JSON.
#[arg(short = 'x', long, help_heading = Some("FLAGS"))]
pub context: bool,
pub context: bool,
/// Strips the given parts from the changelog.
#[arg(short, long, value_name = "PART", value_enum)]
pub strip: Option<Strip>,
pub strip: Option<Strip>,
/// Sets sorting of the commits inside sections.
#[arg(
long,
value_enum,
default_value_t = Sort::Oldest
)]
pub sort: Sort,
pub sort: Sort,
/// Sets the commit range to process.
#[arg(value_name = "RANGE", help_heading = Some("ARGS"))]
pub range: Option<String>,
pub range: Option<String>,
/// Sets the GitHub API token.
#[arg(
long,
Expand All @@ -237,7 +236,7 @@ pub struct Opt {
hide_env_values = true,
hide = !cfg!(feature = "github"),
)]
pub github_token: Option<SecretString>,
pub github_token: Option<SecretString>,
/// Sets the GitHub repository.
#[arg(
long,
Expand All @@ -246,7 +245,7 @@ pub struct Opt {
value_name = "OWNER/REPO",
hide = !cfg!(feature = "github"),
)]
pub github_repo: Option<RemoteValue>,
pub github_repo: Option<RemoteValue>,
/// Sets the GitLab API token.
#[arg(
long,
Expand All @@ -255,7 +254,7 @@ pub struct Opt {
hide_env_values = true,
hide = !cfg!(feature = "gitlab"),
)]
pub gitlab_token: Option<SecretString>,
pub gitlab_token: Option<SecretString>,
/// Sets the GitLab repository.
#[arg(
long,
Expand All @@ -264,7 +263,7 @@ pub struct Opt {
value_name = "OWNER/REPO",
hide = !cfg!(feature = "gitlab"),
)]
pub gitlab_repo: Option<RemoteValue>,
pub gitlab_repo: Option<RemoteValue>,
/// Sets the Bitbucket API token.
#[arg(
long,
Expand All @@ -273,7 +272,7 @@ pub struct Opt {
hide_env_values = true,
hide = !cfg!(feature = "bitbucket"),
)]
pub bitbucket_token: Option<SecretString>,
pub bitbucket_token: Option<SecretString>,
/// Sets the Bitbucket repository.
#[arg(
long,
Expand All @@ -282,7 +281,7 @@ pub struct Opt {
value_name = "OWNER/REPO",
hide = !cfg!(feature = "bitbucket"),
)]
pub bitbucket_repo: Option<RemoteValue>,
pub bitbucket_repo: Option<RemoteValue>,
}

/// Custom type for the remote value.
Expand Down
9 changes: 4 additions & 5 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ pub fn run(mut args: Opt) -> Result<()> {
config.git.tag_pattern.clone_from(&args.tag_pattern);
}

if args.bump_initial_tag.is_some() {
config.bump.initial_tag.clone_from(&args.bump_initial_tag);
}
if args.bump_initial_tag.is_some() {
config.bump.initial_tag.clone_from(&args.bump_initial_tag);
}

// Process the repositories.
let repositories = args.repository.clone().unwrap_or(vec![env::current_dir()?]);
Expand Down Expand Up @@ -515,12 +515,11 @@ pub fn run(mut args: Opt) -> Result<()> {
)?);
}

// Process commits and releases for the changelog.
// Process commits and releases for the changelog.
let mut changelog = Changelog::new(releases, &config)?;

// Print the result.
if args.bump || args.bumped_version {

let next_version = if let Some(next_version) = changelog.bump_version()? {
next_version
} else if let Some(last_version) =
Expand Down

0 comments on commit 1e30cdb

Please sign in to comment.