Skip to content

Commit

Permalink
fix: treat 0.y.z autobumps specially
Browse files Browse the repository at this point in the history
  • Loading branch information
tranzystorekk authored and oknozor committed Oct 11, 2020
1 parent 7c4a1cb commit f113744
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,31 @@ impl VersionIncrement {
}

fn get_next_auto_version(current_version: &Version, commits: &[Commit]) -> Result<Version> {
let mut next_version = current_version.clone();

let major_bump = commits
.iter()
.any(|commit| commit.message.is_breaking_change);
let is_major_bump = || {
current_version.major != 0
&& commits
.iter()
.any(|commit| commit.message.is_breaking_change)
};

let minor_bump = commits
.iter()
.any(|commit| commit.message.commit_type == CommitType::Feature);
let is_minor_bump = || {
commits
.iter()
.any(|commit| commit.message.commit_type == CommitType::Feature)
};

let patch_bump = commits
.iter()
.any(|commit| commit.message.commit_type == CommitType::BugFix);
let is_patch_bump = || {
commits
.iter()
.any(|commit| commit.message.commit_type == CommitType::BugFix)
};

if major_bump {
let mut next_version = current_version.clone();
if is_major_bump() {
next_version.increment_major();
} else if minor_bump {
} else if is_minor_bump() {
next_version.increment_minor();
} else if patch_bump {
} else if is_patch_bump() {
next_version.increment_patch();
} else {
return Err(anyhow!("No commit found to bump current version"));
Expand Down

0 comments on commit f113744

Please sign in to comment.