Class: Reap::Subversion
- Inherits:
-
Object
- Object
- Reap::Subversion
- Includes:
- Utilities::FileUtils, Utilities::ShellUtils
- Defined in:
- lib/reap/systems/subversion.rb
Instance Attribute Summary collapse
-
#branchpath ⇒ Object
Directory to store branches.
-
#dryrun ⇒ Object
Operate in dryrun mode.
-
#message ⇒ Object
Optional commit message.
-
#prefix ⇒ Object
Prefix to use on tag folder.
-
#project ⇒ Object
Project name (for repository).
-
#protocol ⇒ Object
The URL protocol to use.
-
#repository ⇒ Object
Developers URL to repository.
-
#tagpath ⇒ Object
Directory to store tags.
-
#username ⇒ Object
Username.
-
#version ⇒ Object
Current version of project.
Attributes included from Utilities::OptionUtils
Instance Method Summary collapse
-
#branch(options = {}) ⇒ Object
Branch current version.
-
#developer_domain ⇒ Object
Developer domain is “username@repository”.
-
#initialize(options = {}) ⇒ Subversion
constructor
New Subversion object.
-
#log(file = nil) ⇒ Object
Create a change log.
- #log_xml(file) ⇒ Object
-
#tag(options = {}) ⇒ Object
Tag current version.
Methods included from Utilities::FileUtils
#bin?, #cd, #command_paths, #dir!, #dir?, directory!, directory?, exist!, exist?, #exists!, #exists?, #file!, #file?, #file_read, #file_write, #fileutils, #glob, #multiglob, #multiglob_r, #out_of_date?, path!, path?, #rm_r, #safe?, #stage, #stage_manifest, #tar_bzip, #tgz, #zip, #ziputils
Methods included from Utilities::ShellUtils
Methods included from Utilities::OptionUtils
#dryrun?, #force?, #trace?, #verbose?
Constructor Details
#initialize(options = {}) ⇒ Subversion
New Subversion object.
TODO: Perhaps format prefix, like:
prefix = prefix + '_' if prefix && prefix !~ /[_-]$/
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/reap/systems/subversion.rb', line 56 def initialize(={}) .each do |k,v| send("#{k}=", v) if respond_to?("#{k}=") end # defaults are for rubyforge @repository ||= "rubyforge.org/var/svn/#{project}" @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/.
45 46 47 |
# File 'lib/reap/systems/subversion.rb', line 45 def branchpath @branchpath end |
#dryrun ⇒ Object
Operate in dryrun mode.
49 50 51 |
# File 'lib/reap/systems/subversion.rb', line 49 def dryrun @dryrun end |
#message ⇒ Object
Optional commit message. This is intended for commandline usage. (Use -m for shorthand).
37 38 39 |
# File 'lib/reap/systems/subversion.rb', line 37 def @message end |
#prefix ⇒ Object
Prefix to use on tag folder. Default is no prefix.
32 33 34 |
# File 'lib/reap/systems/subversion.rb', line 32 def prefix @prefix end |
#project ⇒ Object
Project name (for repository).
12 13 14 |
# File 'lib/reap/systems/subversion.rb', line 12 def project @project end |
#protocol ⇒ Object
The URL protocol to use. Defaults to “svn+ssh”.
28 29 30 |
# File 'lib/reap/systems/subversion.rb', line 28 def protocol @protocol end |
#repository ⇒ Object
Developers URL to repository. Defaults to Rubyforge address.
20 21 22 |
# File 'lib/reap/systems/subversion.rb', line 20 def repository @repository end |
#tagpath ⇒ Object
Directory to store tags. Defaults to tags/.
41 42 43 |
# File 'lib/reap/systems/subversion.rb', line 41 def tagpath @tagpath end |
#username ⇒ Object
Username. Defaults to ENV.
24 25 26 |
# File 'lib/reap/systems/subversion.rb', line 24 def username @username end |
#version ⇒ Object
Current version of project.
16 17 18 |
# File 'lib/reap/systems/subversion.rb', line 16 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).
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/reap/systems/subversion.rb', line 84 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 case ask("Branch: #{url} ? [yN]").strip.downcase when 'y', 'yes' #sh "svn copy #{protocol}://#{username}@#{repository}/trunk #{url}" sh "svn copy . #{url}" end end |
#developer_domain ⇒ Object
Developer domain is “username@repository”.
75 76 77 |
# File 'lib/reap/systems/subversion.rb', line 75 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?
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/reap/systems/subversion.rb', line 144 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
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/reap/systems/subversion.rb', line 165 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="#{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).
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/reap/systems/subversion.rb', line 107 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 case ask("Tag: #{url} ? [yN]").strip.downcase when 'y', 'yes' #sh "svn copy #{protocol}://#{username}@#{repository}/trunk #{url}" sh "svn copy . #{url}" end end |