Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support build with TagNNN

  • Loading branch information...
commit 0a682b031a6ba6c3de635687b7f1986be5bcd9a5 1 parent 99202e1
@drh-stanford drh-stanford authored
View
11 README.md
@@ -42,8 +42,9 @@ Use `bumper_version` anywhere you need access to the current version in your rak
Pre-release versioning
----------------------
-You can append a hyphen tag to the *patch* version, e.g., 1.0.0-alpha, 1.0.0-beta, 1.0.0-beta2,
-1.0.0-gamma, 1.0.0-rc, 1.0.0-rc2, etc.
+You can append a hyphen tag to the *patch* version, e.g., 1.0.0-alpha, 1.0.0-beta, 1.0.0-beta2, 1.0.0-gamma, 1.0.0-rc, 1.0.0-rc2, etc.
+
+Or you can prepend a tag to the *build* version, e.g., 1.0.0.alpha1, 1.0.0.beta1, 1.0.0.rc3, etc.
$ rake bump:init
version: 0.0.0.0
@@ -65,6 +66,12 @@ You can append a hyphen tag to the *patch* version, e.g., 1.0.0-alpha, 1.0.0-bet
version: 0.1.2.0
$ rake bump:minor
version: 0.2.0.0
+ $ rake bump:build[beta]
+ version: 0.2.0.beta1
+ $ rake bump:build
+ version: 0.2.0.beta2
+ $ rake bump:build[rc]
+ version: 0.2.0.rc1
$ rake bump:patch[alpha]
version: 0.2.1-alpha.0
View
2  VERSION
@@ -1 +1 @@
-0.4.1.pre1
+0.4.1.pre2
View
19 lib/bumper/version.rb
@@ -30,19 +30,19 @@ def initialize(v = '0.0.0.0')
@v[:minor] = $2.to_i
@v[:patch] = $3.to_i
@v[:patch_tag]= $4.empty?? nil : $4.to_s
- elsif v =~ /^(\d+)\.(\d+)\.(\d+)\.([A-Za-z\d]+)$/ # 0.0.0.0
+ elsif v =~ /^(\d+)\.(\d+)\.(\d+)\.([A-Za-z]*\d+)$/ # 0.0.0.a0
@v[:major] = $1.to_i
@v[:minor] = $2.to_i
@v[:patch] = $3.to_i
@v[:build] = $4.to_s
- elsif v =~ /^(\d+)\.(\d+)\.(\d+)-([A-Za-z\d]+)\.([A-Za-z\d]+)$/ # 0.0.0-alpha.0
+ elsif v =~ /^(\d+)\.(\d+)\.(\d+)-([A-Za-z\d]+)\.([A-Za-z]*\d+)$/ # 0.0.0-alpha.0
@v[:major] = $1.to_i
@v[:minor] = $2.to_i
@v[:patch] = $3.to_i
@v[:patch_tag]= $4.empty?? nil : $4.to_s
@v[:build] = $5.to_s
else
- raise ArgumentError, "Invalid version format (MAJOR.MINOR[.PATCH[-TAG[.BUILD]]]): #{v}"
+ raise ArgumentError, "Invalid version format major.minor[.patch[-tag[.[tag]build]]]: #{v}"
end
end
@@ -62,7 +62,7 @@ def bump_patch_tag tag
return @v[:patch_tag] = tag
elsif patch_tag.start_with? tag
# ensure tag ends with number
- if patch_tag !~ %r{\d$}
+ if patch_tag !~ %r{\d+$}
@v[:patch_tag] = patch_tag + '1' # required for succ to work
end
# increment this tag
@@ -73,7 +73,16 @@ def bump_patch_tag tag
end
def bump(part)
- return (@v[part] = (build.nil?? '1' : build.succ)) if part == :build
+ if part == :build
+ if build.nil?
+ @v[part] = '1'
+ elsif build =~ /^([^\d]+)(\d+)$/
+ @v[part] = $1 + ($2.to_i + 1).to_s
+ else
+ @v[part] = build.succ
+ end
+ return @v[part]
+ end
@v[:build] = '0' unless build.nil?
if part == :patch and not @v[:patch_tag].nil?
@v[:patch_tag] = nil # just drop the tag
View
10 lib/version_bumper.rb
@@ -41,9 +41,13 @@ def bumper_version
persist!
end
- desc "bump build"
- task :build do
- bumper_version.bump_build
+ desc "bump build or bump build[tag]"
+ task :build, :tag do |t, args|
+ if args[:tag] and not args[:tag].empty?
+ bumper_version.build = args[:tag] =~ /\d+$/ ? args[:tag] : (args[:tag] + '1')
+ else
+ bumper_version.bump_build
+ end
persist!
end
View
31 test/test_version_bumper.rb
@@ -141,18 +141,45 @@ def test_that_bumping_with_prereleases
assert_equal '0.2.0.0', v.to_s
assert_equal 'alpha', v.bump_patch_tag('alpha')
assert_equal '0.2.1-alpha.0', v.to_s
+ assert_equal 3, v.bump_minor
+ assert_equal '0.3.0.0', v.to_s
+ v.build = 'rc1'
+ assert_equal '0.3.0.rc1', v.to_s
+ assert_equal 'rc2', v.bump_build
+ assert_equal '0.3.0.rc2', v.to_s
end
+ def test_build_rollover0
+ v = Bumper::Version.new('0.0.0.rc9')
+ assert_equal 'rc9', v.build
+ assert_equal 'rc10', v.bump_build
+ assert_equal '0.0.0.rc10', v.to_s
+ end
+
+ def test_build_rollover00
+ v = Bumper::Version.new('0.0.0.rc99')
+ assert_equal 'rc100', v.bump_build
+ assert_equal '0.0.0.rc100', v.to_s
+ end
+
+ def test_build_rollover000
+ v = Bumper::Version.new('0.0.0.rc999')
+ assert_equal 'rc1000', v.bump_build
+ assert_equal '0.0.0.rc1000', v.to_s
+ end
+
def test_patch_tag_messy
v = Bumper::Version.new('0.0.0-alpha.0')
assert_equal 'alpha', v.patch_tag
v.patch_tag = nil
- puts v.patch_tag
+ # puts v.patch_tag
assert_equal nil, v.patch_tag
end
def test_invalid_versions
- assert_raises(ArgumentError) {Bumper::Version.new('0.0.alpha.0')}
+ %w{0.0.0.1rc9 0.0.0.9a}.each do |v|
+ assert_raises(ArgumentError) {Bumper::Version.new(v)}
+ end
end
def test_backward_compat
Please sign in to comment.
Something went wrong with that request. Please try again.