Author: assaf
Date: Fri Sep 26 12:58:49 2008
New Revision: 699470
URL: http://svn.apache.org/viewvc?rev=699470&view=rev
Log:
BUILD-153 Tags aren't customizable anymore. Fixed, see documentation for
Release.tag_name.
Modified:
incubator/buildr/trunk/CHANGELOG
incubator/buildr/trunk/lib/buildr/core/build.rb
incubator/buildr/trunk/spec/core/build_spec.rb
Modified: incubator/buildr/trunk/CHANGELOG
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/CHANGELOG?rev=699470&r1=699469&r2=699470&view=diff
==============================================================================
--- incubator/buildr/trunk/CHANGELOG (original)
+++ incubator/buildr/trunk/CHANGELOG Fri Sep 26 12:58:49 2008
@@ -6,8 +6,8 @@
* Added: Release task support for alternative SVN repository layout
(e.g., http://my.repo.org/trunk/foo).
* Added: BUILDR-148 It is now possible to set the version of various 3rd
- party libraries from the build.yml file. Supported libraries include
- Ant and the various test and BDD frameworks.
+ party libraries from the build.yml file. Supported libraries
+ include Ant and the various test and BDD frameworks.
* Change: Error reporting now shows 'buildr aborted!' (used to say rake),
more of the stack trace without running --trace, and when running
with supported terminal, error message is red.
@@ -20,6 +20,9 @@
* Change: BUILDR-141 Removed NEXT_VERSION from release task.
* Change: BUILDR-148 ant-junit no longer included in root classpath, but
specified during taskdef.
+* Change: BUILDR-153 To customize the SVN tag used by the release task, set
+ Release.tag_name to either the tag value or a proc that takes the
+ version number and return the desired tag.
* Fixed: BUILDR-135. Extracted reusable replacement logic into Filter::Mapper
* Fixed: BUILDR-129. Modifying a project manifest should not alter it's
parent project manifest.
Modified: incubator/buildr/trunk/lib/buildr/core/build.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/build.rb?rev=699470&r1=699469&r2=699470&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/build.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/build.rb Fri Sep 26 12:58:49 2008
@@ -112,11 +112,11 @@
class Svn
class << self
- def commit file, message
+ def commit(file, message)
svn 'commit', '-m', message, file
end
- def copy dir, url, message
+ def copy(dir, url, message)
svn 'copy', dir, url, '-m', message
end
@@ -125,7 +125,7 @@
svn('info').scan(/URL: (.*)/)[0][0]
end
- def remove url, message
+ def remove(url, message)
svn 'remove', url, '-m', message
end
@@ -152,12 +152,18 @@
THIS_VERSION_PATTERN = /(THIS_VERSION|VERSION_NUMBER)\s*=\s*(["'])(.*)\2/
class << self
+
+ # Use this to specify a different tag name for tagging the release in
source control.
+ # You can set the tag name or a proc that will be called with the
version number,
+ # for example:
+ # Release.tag_name = lambda { |ver| "foo-#{ver}" }
+ attr_accessor :tag_name
# :call-seq:
# make()
#
# Make a release.
- def make()
+ def make
check
with_release_candidate_version do |release_candidate_buildfile|
options = ['--buildfile', release_candidate_buildfile, 'DEBUG=no']
@@ -188,12 +194,14 @@
# Can handle the two standard repository layouts.
# - http://my.repo/foo/trunk => http://my.repo/foo/tags/1.0.0
# - http://my.repo/trunk/foo => http://my.repo/tags/foo/1.0.0
- def tag_url svn_url, version
+ def tag_url(svn_url, version)
trunk_or_branches = Regexp.union(%r{^(.*)/trunk(.*)$},
%r{^(.*)/branches(.*)/([^/]*)$})
match = trunk_or_branches.match(svn_url)
prefix = match[1] || match[3]
suffix = match[2] || match[4]
- prefix + '/tags' + suffix + '/' + version
+ tag = tag_name || version
+ tag = tag.call(version) if Proc === tag
+ prefix + '/tags' + suffix + '/' + tag
end
# :call-seq:
@@ -201,7 +209,7 @@
#
# Check that we don't have any local changes in the working copy. Fails
if it finds anything
# in the working copy that is not checked into source control.
- def check()
+ def check
fail "SVN URL must contain 'trunk' or 'branches/...'" unless
Svn.repo_url =~ /(trunk)|(branches.*)$/
fail "Uncommitted SVN files violate the First Principle Of
Release!\n#{Svn.uncommitted_files}" unless Svn.uncommitted_files.empty?
end
@@ -212,11 +220,11 @@
# buildr(tasks, options)
#
# Calls another instance of buildr.
- def buildr tasks, options
+ def buildr(tasks, options)
sh "#{command} _#{Buildr::VERSION}_ #{tasks.join(' ')}
#{options.join(' ')}"
end
- def command() #:nodoc:
+ def command #:nodoc:
Config::CONFIG['arch'] =~ /dos|win32/i ? $PROGRAM_NAME.ext('cmd') :
$PROGRAM_NAME
end
@@ -255,7 +263,7 @@
#
# This method yields to the block with the current (this) version number
as an array and expects
# the block to update it.
- def change_version()
+ def change_version
this_version = extract_version
new_version = this_version.split('.')
yield(new_version)
Modified: incubator/buildr/trunk/spec/core/build_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/core/build_spec.rb?rev=699470&r1=699469&r2=699470&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/core/build_spec.rb (original)
+++ incubator/buildr/trunk/spec/core/build_spec.rb Fri Sep 26 12:58:49 2008
@@ -193,100 +193,206 @@
end
-describe Buildr::Release, '#make' do
- before do
- write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
- # Prevent a real call to a spawned buildr process.
- Release.stub!(:buildr)
- Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
- Svn.stub!(:uncommitted_files).and_return('')
- Svn.stub!(:remove)
- Svn.stub!(:copy)
- Svn.stub!(:commit)
- end
-
- it 'should tag a release with the release version' do
- Svn.should_receive(:copy).with(Dir.pwd,
'http://my.repo.org/foo/tags/1.0.0', 'Release 1.0.0').and_return {
- file('buildfile').should contain('VERSION_NUMBER = "1.0.0"')
- }
- Release.make
- end
-
- it 'should update the buildfile with the next version number' do
- Release.make
- file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
- end
+describe Buildr::Release do
- it 'should commit the updated buildfile' do
- Svn.should_receive(:commit).with(File.expand_path('buildfile'), 'Changed
version number to 1.0.1-SNAPSHOT').and_return {
+ describe '#make' do
+ before do
+ write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
+ # Prevent a real call to a spawned buildr process.
+ Release.stub!(:buildr)
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
+ Svn.stub!(:uncommitted_files).and_return('')
+ Svn.stub!(:remove)
+ Svn.stub!(:copy)
+ Svn.stub!(:commit)
+ end
+
+ it 'should tag a release with the release version' do
+ Svn.should_receive(:copy).with(Dir.pwd,
'http://my.repo.org/foo/tags/1.0.0', 'Release 1.0.0').and_return {
+ file('buildfile').should contain('VERSION_NUMBER = "1.0.0"')
+ }
+ Release.make
+ end
+
+ it 'should update the buildfile with the next version number' do
+ Release.make
file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
- }
- Release.make
+ end
+
+ it 'should commit the updated buildfile' do
+ Svn.should_receive(:commit).with(File.expand_path('buildfile'), 'Changed
version number to 1.0.1-SNAPSHOT').and_return {
+ file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
+ }
+ Release.make
+ end
end
-end
-describe Buildr::Release, '#check' do
- before do
- Svn.stub!(:uncommitted_files).and_return('')
- end
-
- it 'should accept to release from the trunk' do
- Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
- lambda { Release.check }.should_not raise_error
- end
-
- it 'should accept to release from a branch' do
- Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/branches/1.0')
- lambda { Release.check }.should_not raise_error
- end
-
- it 'should reject releasing from a tag' do
- Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/tags/1.0.0')
- lambda { Release.check }.should raise_error(RuntimeError, "SVN URL must
contain 'trunk' or 'branches/...'")
+ describe '#check' do
+ before do
+ Svn.stub!(:uncommitted_files).and_return('')
+ end
+
+ it 'should accept to release from the trunk' do
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
+ lambda { Release.check }.should_not raise_error
+ end
+
+ it 'should accept to release from a branch' do
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/branches/1.0')
+ lambda { Release.check }.should_not raise_error
+ end
+
+ it 'should reject releasing from a tag' do
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/tags/1.0.0')
+ lambda { Release.check }.should raise_error(RuntimeError, "SVN URL must
contain 'trunk' or 'branches/...'")
+ end
+
+ it 'should reject a non standard repository layout' do
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/bar')
+ lambda { Release.check }.should raise_error(RuntimeError, "SVN URL must
contain 'trunk' or 'branches/...'")
+ end
+
+ it 'should reject an uncommitted file' do
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
+ Svn.stub!(:uncommitted_files).and_return('M foo.rb')
+ lambda { Release.check }.should raise_error(RuntimeError,
+ "Uncommitted SVN files violate the First Principle Of Release!\n" +
+ "M foo.rb")
+ end
end
- it 'should reject a non standard repository layout' do
- Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/bar')
- lambda { Release.check }.should raise_error(RuntimeError, "SVN URL must
contain 'trunk' or 'branches/...'")
- end
- it 'should reject an uncommitted file' do
- Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
- Svn.stub!(:uncommitted_files).and_return('M foo.rb')
- lambda { Release.check }.should raise_error(RuntimeError,
- "Uncommitted SVN files violate the First Principle Of Release!\n" +
- "M foo.rb")
+ describe '#extract_version' do
+ it 'should extract VERSION_NUMBER with single quotes' do
+ write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
+ Release.extract_version.should == '1.0.0-SNAPSHOT'
+ end
+
+ it 'should extract VERSION_NUMBER with double quotes' do
+ write 'buildfile', %{VERSION_NUMBER = "1.0.1-SNAPSHOT"}
+ Release.extract_version.should == '1.0.1-SNAPSHOT'
+ end
+
+ it 'should extract VERSION_NUMBER without any spaces' do
+ write 'buildfile', "VERSION_NUMBER='1.0.2-SNAPSHOT'"
+ Release.extract_version.should == '1.0.2-SNAPSHOT'
+ end
+
+ it 'should extract THIS_VERSION as an alternative to VERSION_NUMBER' do
+ write 'buildfile', "THIS_VERSION = '1.0.3-SNAPSHOT'"
+ Release.extract_version.should == '1.0.3-SNAPSHOT'
+ end
+
+ it 'should complain if no current version number' do
+ write 'buildfile', 'define foo'
+ lambda { Release.extract_version }.should raise_error('Looking for
THIS_VERSION = "..." in your Buildfile, none found')
+ end
end
-end
-
-describe Buildr::Release, '#extract_version' do
-
- it 'should extract VERSION_NUMBER with single quotes' do
- write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
- Release.extract_version.should == '1.0.0-SNAPSHOT'
+
+ # Reference:
http://svnbook.red-bean.com/en/1.4/svn.reposadmin.planning.html#svn.reposadmin.projects.chooselayout
+ describe '#tag url' do
+ it 'should accept to tag foo/trunk' do
+ Release.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should ==
'http://my.repo.org/foo/tags/1.0.0'
+ end
+
+ it 'should accept to tag foo/branches/1.0' do
+ Release.tag_url('http://my.repo.org/foo/branches/1.0', '1.0.1').should
== 'http://my.repo.org/foo/tags/1.0.1'
+ end
+
+ it 'should accept to tag trunk/foo' do
+ Release.tag_url('http://my.repo.org/trunk/foo', '1.0.0').should ==
'http://my.repo.org/tags/foo/1.0.0'
+ end
+
+ it 'should accept to tag branches/foo/1.0' do
+ Release.tag_url('http://my.repo.org/branches/foo/1.0', '1.0.0').should
== 'http://my.repo.org/tags/foo/1.0.0'
+ end
+
+ it 'should use tag specified by tag_name' do
+ Release.tag_name = 'first'
+ Release.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should ==
'http://my.repo.org/foo/tags/first'
+ end
+
+ it 'should use tag returned by tag_name if tag_name is a proc' do
+ Release.tag_name = lambda { |version| "buildr-#{version}" }
+ Release.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should ==
'http://my.repo.org/foo/tags/buildr-1.0.0'
+ end
+
+ after { Release.tag_name = nil }
end
-
- it 'should extract VERSION_NUMBER with double quotes' do
- write 'buildfile', %{VERSION_NUMBER = "1.0.1-SNAPSHOT"}
- Release.extract_version.should == '1.0.1-SNAPSHOT'
+
+
+ describe '#with_release_candidate_version' do
+ before do
+ Buildr.application.stub!(:buildfile).and_return(file('buildfile'))
+ write 'buildfile', "THIS_VERSION = '1.1.0-SNAPSHOT'"
+ end
+
+ it 'should yield the name of the release candidate buildfile' do
+ Release.send :with_release_candidate_version do |new_filename|
+ File.read(new_filename).should == %{THIS_VERSION = "1.1.0"}
+ end
+ end
+
+ it 'should yield a name different from the original buildfile' do
+ Release.send :with_release_candidate_version do |new_filename|
+ new_filename.should_not point_to_path('buildfile')
+ end
+ end
end
-
- it 'should extract VERSION_NUMBER without any spaces' do
- write 'buildfile', "VERSION_NUMBER='1.0.2-SNAPSHOT'"
- Release.extract_version.should == '1.0.2-SNAPSHOT'
+
+
+ describe '#tag_release' do
+ before do
+ write 'buildfile', "THIS_VERSION = '1.0.1'"
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
+ Svn.stub!(:copy)
+ Svn.stub!(:remove)
+ end
+
+ it 'should tag the working copy' do
+ Svn.should_receive(:copy).with(Dir.pwd,
'http://my.repo.org/foo/tags/1.0.1', 'Release 1.0.1')
+ Release.send :tag_release
+ end
+
+ it 'should remove the tag if it already exists' do
+ Svn.should_receive(:remove).with('http://my.repo.org/foo/tags/1.0.1',
'Removing old copy')
+ Release.send :tag_release
+ end
+
+ it 'should accept that the tag does not exist' do
+ Svn.stub!(:remove).and_raise(RuntimeError)
+ Release.send :tag_release
+ end
+
+ it 'should inform the user' do
+ lambda { Release.send :tag_release }.should show_info('Tagging release
1.0.1')
+ end
end
-
- it 'should extract THIS_VERSION as an alternative to VERSION_NUMBER' do
- write 'buildfile', "THIS_VERSION = '1.0.3-SNAPSHOT'"
- Release.extract_version.should == '1.0.3-SNAPSHOT'
+
+
+ describe '#commit_new_snapshot' do
+ before do
+ write 'buildfile', 'THIS_VERSION = "1.0.0"'
+ Svn.stub!(:commit)
+ end
+
+ it 'should update the buildfile with a new version number' do
+ Release.send :commit_new_snapshot
+ file('buildfile').should contain('THIS_VERSION = "1.0.1-SNAPSHOT"')
+ end
+
+ it 'should commit the new buildfile on the trunk' do
+ Svn.should_receive(:commit).with(File.expand_path('buildfile'), 'Changed
version number to 1.0.1-SNAPSHOT')
+ Release.send :commit_new_snapshot
+ end
+
+ it 'should inform the user of the new version' do
+ lambda { Release.send :commit_new_snapshot }.should show_info('Current
version is now 1.0.1-SNAPSHOT')
+ end
end
- it 'should complain if no current version number' do
- write 'buildfile', 'define foo'
- lambda { Release.extract_version }.should raise_error('Looking for
THIS_VERSION = "..." in your Buildfile, none found')
- end
end
@@ -306,95 +412,4 @@
EOF
Svn.repo_url.should == 'http://my.repo.org/foo/trunk'
end
-end
-
-
-# Reference:
http://svnbook.red-bean.com/en/1.4/svn.reposadmin.planning.html#svn.reposadmin.projects.chooselayout
-describe Buildr::Release, '#tag url' do
- it 'should accept to tag foo/trunk' do
- Release.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should ==
'http://my.repo.org/foo/tags/1.0.0'
- end
-
- it 'should accept to tag foo/branches/1.0' do
- Release.tag_url('http://my.repo.org/foo/branches/1.0', '1.0.1').should ==
'http://my.repo.org/foo/tags/1.0.1'
- end
-
- it 'should accept to tag trunk/foo' do
- Release.tag_url('http://my.repo.org/trunk/foo', '1.0.0').should ==
'http://my.repo.org/tags/foo/1.0.0'
- end
-
- it 'should accept to tag branches/foo/1.0' do
- Release.tag_url('http://my.repo.org/branches/foo/1.0', '1.0.0').should ==
'http://my.repo.org/tags/foo/1.0.0'
- end
-end
-
-
-describe Buildr::Release, '#with_release_candidate_version' do
- before do
- Buildr.application.stub!(:buildfile).and_return(file('buildfile'))
- write 'buildfile', "THIS_VERSION = '1.1.0-SNAPSHOT'"
- end
-
- it 'should yield the name of the release candidate buildfile' do
- Release.send :with_release_candidate_version do |new_filename|
- File.read(new_filename).should == %{THIS_VERSION = "1.1.0"}
- end
- end
-
- it 'should yield a name different from the original buildfile' do
- Release.send :with_release_candidate_version do |new_filename|
- new_filename.should_not point_to_path('buildfile')
- end
- end
-end
-
-
-describe Buildr::Release, '#tag_release' do
- before do
- write 'buildfile', "THIS_VERSION = '1.0.1'"
- Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
- Svn.stub!(:copy)
- Svn.stub!(:remove)
- end
-
- it 'should tag the working copy' do
- Svn.should_receive(:copy).with(Dir.pwd,
'http://my.repo.org/foo/tags/1.0.1', 'Release 1.0.1')
- Release.send :tag_release
- end
-
- it 'should remove the tag if it already exists' do
- Svn.should_receive(:remove).with('http://my.repo.org/foo/tags/1.0.1',
'Removing old copy')
- Release.send :tag_release
- end
-
- it 'should accept that the tag does not exist' do
- Svn.stub!(:remove).and_raise(RuntimeError)
- Release.send :tag_release
- end
-
- it 'should inform the user' do
- lambda { Release.send :tag_release }.should show_info('Tagging release
1.0.1')
- end
-end
-
-
-describe Buildr::Release, '#commit_new_snapshot' do
- before do
- write 'buildfile', 'THIS_VERSION = "1.0.0"'
- Svn.stub!(:commit)
- end
-
- it 'should update the buildfile with a new version number' do
- Release.send :commit_new_snapshot
- file('buildfile').should contain('THIS_VERSION = "1.0.1-SNAPSHOT"')
- end
-
- it 'should commit the new buildfile on the trunk' do
- Svn.should_receive(:commit).with(File.expand_path('buildfile'), 'Changed
version number to 1.0.1-SNAPSHOT')
- Release.send :commit_new_snapshot
- end
-
- it 'should inform the user of the new version' do
- lambda { Release.send :commit_new_snapshot }.should show_info('Current
version is now 1.0.1-SNAPSHOT')
- end
end
\ No newline at end of file