Module: Buildr::Svn
- Defined in:
- lib/buildr/core/build.rb
Overview
:nodoc:
Class Method Summary collapse
- .commit(file, message) ⇒ Object
- .copy(dir, url, message) ⇒ Object
- .remove(url, message) ⇒ Object
-
.repo_url ⇒ Object
Return the current SVN URL.
-
.svn(*args) ⇒ Object
:call-seq: svn(*args).
- .tag(tag_name) ⇒ Object
-
.tag_url(svn_url, tag) ⇒ Object
:call-seq: tag_url(svn_url, version) => tag_url.
-
.uncommitted_files ⇒ Object
Status check reveals modified files, but also SVN externals which we can safely ignore.
Class Method Details
.commit(file, message) ⇒ Object
188 189 190 |
# File 'lib/buildr/core/build.rb', line 188 def commit(file, ) svn 'commit', '-m', , file end |
.copy(dir, url, message) ⇒ Object
213 214 215 |
# File 'lib/buildr/core/build.rb', line 213 def copy(dir, url, ) svn 'copy', '--parents', dir, url, '-m', end |
.remove(url, message) ⇒ Object
217 218 219 |
# File 'lib/buildr/core/build.rb', line 217 def remove(url, ) svn 'remove', url, '-m', end |
.repo_url ⇒ Object
Return the current SVN URL
209 210 211 |
# File 'lib/buildr/core/build.rb', line 209 def repo_url svn('info', '--xml')[/<url>(.*?)<\/url>/, 1].strip end |
.svn(*args) ⇒ Object
:call-seq:
svn(*args)
Executes a SVN command and returns the output. Throws exception if the exit status is not zero. For example:
svn 'commit'
171 172 173 174 175 |
# File 'lib/buildr/core/build.rb', line 171 def svn(*args) output = `svn #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}` fail "SVN command failed with status #{$?.exitstatus}" unless $?.exitstatus == 0 return output end |
.tag(tag_name) ⇒ Object
177 178 179 180 181 |
# File 'lib/buildr/core/build.rb', line 177 def tag(tag_name) url = tag_url repo_url, tag_name remove url, 'Removing old copy' rescue nil copy Dir.pwd, url, "Release #{tag_name}" end |
.tag_url(svn_url, tag) ⇒ Object
:call-seq:
tag_url(svn_url, version) => tag_url
Returns the SVN url for the tag. Can tag from the trunk or from branches. 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
200 201 202 203 204 205 206 |
# File 'lib/buildr/core/build.rb', line 200 def tag_url(svn_url, tag) 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 + '/' + tag end |
.uncommitted_files ⇒ Object
Status check reveals modified files, but also SVN externals which we can safely ignore.
184 185 186 |
# File 'lib/buildr/core/build.rb', line 184 def uncommitted_files svn('status', '--ignore-externals').split("\n").reject { |line| line =~ /^X\s/ } end |