Class: Reap::Systems::Svn
Overview
Subversion
Source control system for Subversion. Provides:
log
log_xml
tag
branch
Options are:
repository Developers URL to repository. Defaults to Rubyforge address.
username Username. Defaults to ENV['RUBYFORGE_USERNAME'].
protocol The URL protocol to use. Defaults to "svn+ssh".
prefix Prefix to use on tag folder. Default is no prefix.
tagpath Directory to store tags. Defaults to tags/.
branchpath Directory to store branches. Defaults to branches/.
Instance Attribute Summary collapse
-
#branchpath ⇒ Object
Directory to store branches.
-
#message ⇒ Object
Optional commit message.
-
#prefix ⇒ Object
Prefix to use on tag folder.
-
#protocol ⇒ Object
The URL protocol to use.
-
#repository ⇒ Object
Developers URL to repository.
-
#tagpath ⇒ Object
Directory to store tags.
-
#unixname ⇒ Object
Project unixname (for repository).
-
#username ⇒ Object
Username.
-
#version ⇒ Object
Current version of project.
Attributes inherited from Tool
Instance Method Summary collapse
-
#branch(options = {}) ⇒ Object
Branch current version.
-
#developer_domain ⇒ Object
Developer domain is “username@repository”.
-
#initialize(project, options = {}) ⇒ Svn
constructor
New Subversion object.
-
#log(file = nil) ⇒ Object
Create a change log.
- #log_xml(file) ⇒ Object
-
#tag(options = {}) ⇒ Object
Tag current version.
Methods inherited from System
detect, factory, inherited, register, registry
Methods included from Utilities
#ask, #bin?, #cd, #command_paths, #compress, #dir!, #dir?, directory!, directory?, #email, exist!, exist?, #exists!, #exists?, #file!, #file?, #fileutils, #glob, #list_option, #multiglob, #multiglob_r, #out_of_date?, #password, path!, path?, #read, #rm_r, #safe?, #sh, #stage, #stage_manifest, #status, #write, #ziputils
Methods inherited from Tool
#debug?, #dryrun?, #force?, from_project, #metadata, #trace?, #verbose?
Constructor Details
#initialize(project, options = {}) ⇒ Svn
New Subversion object.
TODO: Perhaps format prefix, like:
prefix = prefix + '_' if prefix && prefix !~ /[_-]$/
TODO: tie in Metadata#scm, but probably via project/scm.rb.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/reap/systems/svn.rb', line 73 def initialize(project, ={}) = .rekey super(project, ) #settings = (project.settings['svn'] || {}).rekey #options = settings.update(options) [:repository] ||= project..repository [:unixname] ||= project..unixname [:version] = project..version .each do |k,v| send("#{k}=", v) if respond_to?("#{k}=") end # defaults are for rubyforge @repository ||= "rubyforge.org/var/svn/#{unixname}" @username ||= ENV['RUBYFORGE_USERNAME'] @protocol ||= "svn+ssh" @tagpath ||= "tags" @branchpath ||= "branches" if i = @repository.index('//') @repository = @repository[i+2..-1] end end |
Instance Attribute Details
#branchpath ⇒ Object
Directory to store branches. Defaults to branches/.
64 65 66 |
# File 'lib/reap/systems/svn.rb', line 64 def branchpath @branchpath end |
#message ⇒ Object
Optional commit message. This is intended for commandline usage. (Use -m for shorthand).
56 57 58 |
# File 'lib/reap/systems/svn.rb', line 56 def @message end |
#prefix ⇒ Object
Prefix to use on tag folder. Default is no prefix.
51 52 53 |
# File 'lib/reap/systems/svn.rb', line 51 def prefix @prefix end |
#protocol ⇒ Object
The URL protocol to use. Defaults to “svn+ssh”.
47 48 49 |
# File 'lib/reap/systems/svn.rb', line 47 def protocol @protocol end |
#repository ⇒ Object
Developers URL to repository. Defaults to Rubyforge address.
39 40 41 |
# File 'lib/reap/systems/svn.rb', line 39 def repository @repository end |
#tagpath ⇒ Object
Directory to store tags. Defaults to tags/.
60 61 62 |
# File 'lib/reap/systems/svn.rb', line 60 def tagpath @tagpath end |
#unixname ⇒ Object
Project unixname (for repository).
31 32 33 |
# File 'lib/reap/systems/svn.rb', line 31 def unixname @unixname end |
#username ⇒ Object
Username. Defaults to ENV.
43 44 45 |
# File 'lib/reap/systems/svn.rb', line 43 def username @username end |
#version ⇒ Object
Current version of project.
35 36 37 |
# File 'lib/reap/systems/svn.rb', line 35 def version @version end |
Instance Method Details
#branch(options = {}) ⇒ Object
Branch current version.
message Optional commit message. This is intended for commandline
usage. (Use -m for shorthand).
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/reap/systems/svn.rb', line 113 def branch(={}) msg = ['message'] || ['m'] name = "#{prefix}#{version}" path = branchpath.to_s if path == '.' or path.empty? url = "#{protocol}://" + File.join(developer_domain, name) else url = "#{protocol}://" + File.join(developer_domain, path, name) end if dryrun? puts "svn copy . #{url}" else case ask("Branch: #{url} ? [yN]").strip.downcase when 'y', 'yes' #sh "svn copy #{protocol}://#{username}@#{repository}/trunk #{url}" sh "svn copy . #{url}" end end end |
#developer_domain ⇒ Object
Developer domain is “username@repository”.
104 105 106 |
# File 'lib/reap/systems/svn.rb', line 104 def developer_domain "#{username}@#{repository}" end |
#log(file = nil) ⇒ Object
Create a change log.
change File name to store rdoc formated changelog. Default is 'changelog.txt'.
output Path to store rdoc formated changelog. Default is 'log'.
xmlchange File name to store XML formated changelog. Default is 'changelog.xml'.
This also creates a file, if needed, by the same name but with .xsl extension.
xmloutput Path to store XML-formated changelog. Default is 'doc/log'.
If change or xmlchange contain a path separator (‘/’, not ‘'), then it is assumed they provide their own path and the output fields will not be used. This allows you to set change
to “./CHANGES” for instance, without effecting the location of other logs. You can also set change or xmlchange to ’false’ to supress creation altogether.
TODO: Allow for a way to dump the text-based Changelog to standard out. “$stdout” as the filename? TODO: How to apply naming policy from here?
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/reap/systems/svn.rb', line 181 def log(file=nil) #txtlog = file #options['change'] || 'changelog.txt' #txtdir = options['output'] || 'log' #xmllog = options['xmlchange'] || 'changelog.xml' #xmldir = options['xmloutput'] || 'doc/log' #txtlog = File.join(txtdir, txtlog) unless xmllog.include?('/') #xmllog = File.join(xmldir, xmllog) unless xmllog.include?('/') text = changelog_text if dryrun? puts "svn log > #{file}" elsif file mkdir_p(File.dirname(file)) File.open(file, 'w'){|f| f << text } puts "Updated #{file}" else puts text end end |
#log_xml(file) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/reap/systems/svn.rb', line 202 def log_xml(file) #xmldir = options['xmloutput'] || 'doc/log' xslfile = file.chomp(File.extname(file)) + '.xsl' log_xsl(xslfile) text = changelog_xml i = text.index("?>\n") text.insert(i+2, "\n" + %[<?xml-stylesheet href="#{File.basename(xslfile)}" type="text/xsl" ?>]) if dryrun? puts "svn log --xml > #{file}" elsif file mkdir_p(File.dirname(file)) File.open(file, 'w'){ |f| f << text } puts "Updated #{file}" else puts text end end |
#tag(options = {}) ⇒ Object
Tag current version.
message Optional commit message. This is intended for commandline
usage. (Use -m for shorthand).
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/reap/systems/svn.rb', line 140 def tag(={}) msg = ['message'] || ['m'] name = "#{prefix}#{version}" path = tagpath.to_s if path == '.' or path.empty? url = "#{protocol}://" + File.join(developer_domain, name) else url = "#{protocol}://" + File.join(developer_domain, path, name) end if dryrun? puts "svn copy . #{url}" else case ask("Tag: #{url} ? [yN]").strip.downcase when 'y', 'yes' #sh "svn copy #{protocol}://#{username}@#{repository}/trunk #{url}" sh "svn copy . #{url}" end end end |