Skip to content

Commit

Permalink
refactor: --calculation-mode casing agnostic (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperC286 authored Oct 21, 2024
1 parent 6a9a603 commit b096735
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions end-to-end-tests/features/assert_current_version.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: The current version argument supplied is asserted to be equal or greate
When the argument --from-commit-hash is provided as "<from_commit_hash>".
And the argument --from-version is provided as "<from_version>".
And the argument --current-version is provided as "<current_version>".
And the argument --calculation-mode is provided as "Batch".
And the argument --calculation-mode is provided as "batch".
Then the current version assertion passes.


Expand All @@ -22,7 +22,7 @@ Feature: The current version argument supplied is asserted to be equal or greate
When the argument --from-commit-hash is provided as "<from_commit_hash>".
And the argument --from-version is provided as "<from_version>".
And the argument --current-version is provided as "<current_version>".
And the argument --calculation-mode is provided as "Batch".
And the argument --calculation-mode is provided as "batch".
Then the current version assertion fails.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Feature: The increments are batched together and the largest increment determine
Given the repository "<repository>" is cloned and checked out at the commit "<checkout_commit>".
When the argument --from-commit-hash is provided as "<from_commit_hash>".
And the argument --from-version is provided as "<from_version>".
And the argument --calculation-mode is provided as "Batch".
And the argument --calculation-mode is provided as "batch".
Then the returned version should be "<expected_version>".


Expand Down
4 changes: 2 additions & 2 deletions end-to-end-tests/features/from_shortened_commit_hash.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Feature: A shortened Git commit hash can be provided as an argument to indicate
Given the repository "<repository>" is cloned and checked out at the commit "<checkout_commit>".
When the argument --from-commit-hash is provided as "<from_commit_hash>".
And the argument --from-version is provided as "<from_version>".
And the argument --calculation-mode is provided as "Batch".
And the argument --calculation-mode is provided as "batch".
Then the returned version should be "<expected_version>".
Given the arguments are reset.
When the argument --from-commit-hash is provided as "<shortened_from_commit_hash>".
And the argument --from-version is provided as "<from_version>".
And the argument --calculation-mode is provided as "Batch".
And the argument --calculation-mode is provided as "batch".
Then the returned version should be "<expected_version>".


Expand Down
4 changes: 2 additions & 2 deletions end-to-end-tests/features/pre_major_release.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Feature: Breaking changes for pre-major release semantic versions only increment
Given the repository "<repository>" is cloned and checked out at the commit "<checkout_commit>".
When the argument --from-commit-hash is provided as "<from_commit_hash>".
And the argument --from-version is provided as "<post_major_release_from_version>".
And the argument --calculation-mode is provided as "Batch".
And the argument --calculation-mode is provided as "batch".
Then the returned version should be "<post_major_release_expected_version>".
Given the arguments are reset.
When the argument --from-commit-hash is provided as "<from_commit_hash>".
And the argument --from-version is provided as "<pre_major_release_from_version>".
And the argument --calculation-mode is provided as "Batch".
And the argument --calculation-mode is provided as "batch".
Then the returned version should be "<pre_major_release_expected_version>".

Examples:
Expand Down
3 changes: 2 additions & 1 deletion src/calculation_mode/mod.rs → src/calculation_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ use strum_macros::{Display, EnumString};

/// The mode of calculation to use on the range of Commits to calculate the next semantic version.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Display, EnumString)]
#[strum(ascii_case_insensitive)]
pub enum CalculationMode {
/// In batch mode the largest Semantic Versioning increment determined by the Conventional
/// Commits type across all the commits is the only increment applied.
Batch,
/// In consecutive mode each Git commit in the Conventional Commits specification is applied to Semantic Versioning calculation in chronological or der.
/// In consecutive mode each Git commit in the Conventional Commits specification is applied to Semantic Versioning calculation in chronological order.
Consecutive,
}
2 changes: 1 addition & 1 deletion src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub(crate) struct Arguments {

#[arg(
long,
default_value = "Consecutive",
default_value = "consecutive",
help = "The mode of calculation to use on the range of Commits to calculate the next semantic version."
)]
pub(crate) calculation_mode: CalculationMode,
Expand Down

0 comments on commit b096735

Please sign in to comment.