Skip to content

Commit

Permalink
Change/Fix bump to reset lower version nums
Browse files Browse the repository at this point in the history
- v1.1.1 => Major +1 => v2.0.0 (instead of v2.1.1)
- v1.1.1 => Minor +1 => v1.2.0 (instead of v1.2.1)
  • Loading branch information
esotericpig committed Jun 21, 2021
1 parent e57e91c commit befc2cc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/raketeer/bump_ver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,21 @@ def bump!(sem_ver)
sem_ver.major = 0 # There must always be a major version
else
sem_ver.major = 0 if sem_ver.major.nil?

old_major = sem_ver.major
sem_ver.major += @major.to_i

if sem_ver.major != old_major
# Reset minor & patch so that 1.1.1 => 2.0.0.
# If the user wishes, minor & patch will continue
# to be affected after ('+1.+1.+1').
sem_ver.minor = 0
sem_ver.patch = 0

# It's difficult to decide whether to set
# pre-release and build-metadata to nil,
# so just leave them.
end
end
end

Expand All @@ -66,7 +80,16 @@ def bump!(sem_ver)
sem_ver.minor = nil
else
sem_ver.minor = 0 if sem_ver.minor.nil?

old_minor = sem_ver.minor
sem_ver.minor += @minor.to_i

if sem_ver.minor != old_minor
# Reset patch so that 1.1.1 => 1.2.0.
# If the user wishes, patch will continue
# to be affected after ('X.+1.+1').
sem_ver.patch = 0
end
end
end

Expand Down

0 comments on commit befc2cc

Please sign in to comment.