pub struct CalculatorConfig {
pub force_first_version: bool,
/* private fields */
}Expand description
Captures the user configuration set for the bump and version number calculation
The configuration is set following the builder pattern and final build
command creates a Calculator struct.
Fields§
§force_first_version: boolOptional: Force the first version to be calculated as 1.0.0
Implementations§
Source§impl CalculatorConfig
impl CalculatorConfig
Sourcepub fn new() -> CalculatorConfig
pub fn new() -> CalculatorConfig
Initialise a new calculator config by providing the version prefix.
The version prefix identifies the start of the version string in the tag.
Sourcepub fn set_prefix(self, version_prefix: &str) -> Self
pub fn set_prefix(self, version_prefix: &str) -> Self
Set the version prefix.
The version prefix identifies the start of the version string in the tag.
§Example
Where you have a version tag v0.7.9 the configuration should be set as follows:
let calculator = CalculatorConfig::new()
.set_prefix("v")
.build()?;
calculator.report();Sourcepub fn set_subdir(self, subdir: Option<&str>) -> Self
pub fn set_subdir(self, subdir: Option<&str>) -> Self
Set the optional subdir for commit analysis.
The subdir identifies a string by which the commits will be filtered. The objective of the filtering is to limit the calculation to commits related to one crate within a worlspace.
§Example
Where you have a crate called crate2 in a workspace and wish to calculate the version for that crate only.
Note:
A version prefix should be used to identify the relevent crate version tag.
let calculator = CalculatorConfig::new()
.set_prefix("crate2-v")
.set_subdir(Some("crate2"))
.build()?;
calculator.report();Sourcepub fn set_package(self, subdir: Option<&str>) -> Self
pub fn set_package(self, subdir: Option<&str>) -> Self
Set the optional package for workspace subset.
The package identifies a subset of a workspace to consider when calculating the next version.
§Example
Where you have a crate called crate2 in a workspace and wish to calculate the version for that crate only.
Note:
A version prefix should be used to identify the relevent crate version tag.
let calculator = CalculatorConfig::new()
.set_prefix("crate2-v")
.set_package(Some("crate2"))
.build()?;
calculator.report();Sourcepub fn set_bump_report(self, bump_report: bool) -> Self
pub fn set_bump_report(self, bump_report: bool) -> Self
Set the flag indicating if the bump should be reported by the Calculator::report method.
trueindicates that the value should be reportedfalseinidcates that the value should not be reported
Sourcepub fn set_version_report(self, report_number: bool) -> Self
pub fn set_version_report(self, report_number: bool) -> Self
Set the flag indicating if the calculated version number should be reported by the Calculator::report method.
trueindicates that the value should be reportedfalseinidcates that the value should not be reported
Sourcepub fn set_force_bump(self, force_level: ForceBump) -> Self
pub fn set_force_bump(self, force_level: ForceBump) -> Self
Force the bump result ignoring the bump that would be indicated by an analysis of conventional commits.
The forced bump result will be reported and the next vesion will be calculated based on the forced bump level.
§Example
Publish the first production release.
let calculator = CalculatorConfig::new()
.set_prefix("v")
.set_force_bump(ForceBump::First)
.build()?;
calculator.report();Produces the output:
v1.0.0Sourcepub fn add_required_files(self, files: Vec<OsString>) -> Self
pub fn add_required_files(self, files: Vec<OsString>) -> Self
Add a list of files that should be updated if the calculated level of the
conventional commits analysed meets or exceeds the enforcement level set
by CalculatorConfig::set_required_enforcement.
§Examples
§Using feature (default enforcement level)
Require that the README.md and CHANGELOG.md are updated for the calculation
to report successfully if the calculated bump is feature or higher.
let required_files = vec![
OsString::from("README.md"),
OsString::from("CHANGELOG.md"),
];
let calculator = CalculatorConfig::new()
.set_prefix("v")
.add_required_files(required_files)
.build()?;
calculator.report();The bump minor confirms that the checked files have been updated by the
convential commits submitted as part of proposed release.
minorIn the event that one or more of the files was not found but the highest commit reached
the feature threshold the response would be none.
none§Setting breaking as the enforcement level
Require that the README.md and CHANGELOG.md are updated for the calculation
to report successfully if the calculated bump is breaking or higher.
See
// Current version is 1.2.0
let required_files = vec![
OsString::from("README.md"),
OsString::from("CHANGELOG.md"),
];
let calculator = CalculatorConfig::new()
.set_prefix("v")
.add_required_files(required_files)
.set_required_enforcement(Hierarchy::Breaking)
.build()?;
calculator.report();The bump minor indicates that the highest conventional commit in the hierachy
is a feat commit. The commits may or may not includes changes to the required files.
minorThe bump major confirms that the checked files have been updated by the
convential commits submitted as part of proposed release.
majorIn the event that one or more of the files was not found but the highest commit reached
the breaking threshold the response would be none.
noneFiles that may be listed would include README.md and CHANGELOG.md.
Sourcepub fn set_required_enforcement(self, enforce: Hierarchy) -> Self
pub fn set_required_enforcement(self, enforce: Hierarchy) -> Self
Sets the enforcement for the files submitted in CalculatorConfig::add_required_files according to the Hierarchy enum.
§Example
See the second example in CalculatorConfig::add_required_files for the use of set_required_enforcement
Sourcepub fn set_reporting_threshold(self, threshold: Hierarchy) -> Self
pub fn set_reporting_threshold(self, threshold: Hierarchy) -> Self
Set a threshold that must be met before the calculated bump is reported.
The threshold is set based on the Hierarchy enumm.
§Example
Set a threshold of Hierarchy::Feature for reporting of the change bump.
let calculator = CalculatorConfig::new()
.set_prefix("v")
.set_reporting_threshold(Hierarchy::Feature)
.build()?;
calculator.report();The bump minor indicates that the highest conventional commit in the hierachy
is a feat commit.
minorIf the threshold is not met bump is none
noneSourcepub fn set_first_version(self) -> Self
pub fn set_first_version(self) -> Self
Set the flag to force the first version to be calculated as 1.0.0 to true. This is useful in combination with a pre-release to create a pre-release for the for the first production release.
Sourcepub fn build(self) -> Result<Calculator, Error>
pub fn build(self) -> Result<Calculator, Error>
Executes the calculator with the CalculatorConfig returning a completed
Calculator or an Error.
Trait Implementations§
Source§impl Clone for CalculatorConfig
impl Clone for CalculatorConfig
Source§fn clone(&self) -> CalculatorConfig
fn clone(&self) -> CalculatorConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CalculatorConfig
impl Debug for CalculatorConfig
Source§impl Default for CalculatorConfig
impl Default for CalculatorConfig
Source§fn default() -> CalculatorConfig
fn default() -> CalculatorConfig
Source§impl PartialEq for CalculatorConfig
impl PartialEq for CalculatorConfig
impl Eq for CalculatorConfig
impl StructuralPartialEq for CalculatorConfig
Auto Trait Implementations§
impl Freeze for CalculatorConfig
impl RefUnwindSafe for CalculatorConfig
impl Send for CalculatorConfig
impl Sync for CalculatorConfig
impl Unpin for CalculatorConfig
impl UnwindSafe for CalculatorConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.