Skip to content

Commit

Permalink
fix: properly reset semver values when bumping
Browse files Browse the repository at this point in the history
The previous implementation was too naive. For example, when bumping a
minor version the patch would remain. Now it will properly reset the
lower version values to 0. Prerelease and build version numbers are
reset to empty, so these will need to be specified manually to be used.
  • Loading branch information
justinrubek committed May 16, 2024
1 parent 9e8110c commit 594d039
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/versioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,23 @@ pub fn increment_version(
VersionIncrement::Manual(version) => version,
VersionIncrement::Major => {
version.major += 1;
version.minor = 0;
version.patch = 0;
version.build = semver::BuildMetadata::EMPTY;
version.pre = semver::Prerelease::EMPTY;
version
}
VersionIncrement::Minor => {
version.minor += 1;
version.patch = 0;
version.build = semver::BuildMetadata::EMPTY;
version.pre = semver::Prerelease::EMPTY;
version
}
VersionIncrement::Patch => {
version.patch += 1;
version.build = semver::BuildMetadata::EMPTY;
version.pre = semver::Prerelease::EMPTY;
version
}
}
Expand Down

0 comments on commit 594d039

Please sign in to comment.