Class: SvnAuto::Svn
- Inherits:
-
Object
- Object
- SvnAuto::Svn
- Defined in:
- lib/svnauto/svn.rb
Class Method Summary collapse
-
._svn(*args, &block) ⇒ Object
Run a svn subcommand.
-
.branch(project, source, dest, options = {}) ⇒ Object
create a branch using svn copy.
-
.current_revision(path) ⇒ Object
get the current revision number from the given path.
-
.has_path(path) ⇒ Object
Check to see if the given path exists in the repository.
Class Method Details
._svn(*args, &block) ⇒ Object
Run a svn subcommand
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/svnauto/svn.rb', line 35 def self._svn (*args, &block) subcommand = caller(0)[0].sub(/^.*:in\s`([^']+).*$/, '\1') shell_line = "#{subcommand} #{args.join(' ')}" Constants::TERMINAL.say(Constants::TERMINAL.color("svn #{shell_line}", :yellow)) if $DEBUG block ||= lambda {|line| print(line)} subprocess('svn', subcommand, *args, &block) if $? != 0 and !['info', 'list', 'merge'].include?(subcommand) raise "svn command failed: #{shell_line}" end $? == 0 end |
.branch(project, source, dest, options = {}) ⇒ Object
create a branch using svn copy
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/svnauto/svn.rb', line 75 def self.branch (project, source, dest, ={}) return if self.has_path(dest) configuration = { :revision => 'HEAD', }.update() relative_dest = dest.sub("#{project.url}/", '') dest_dirs = relative_dest.split(/\//) dest_dirs.pop # don't need the last one dest_path = project.url branch_or_tag = dest.match(/branches/) ? 'branch' : 'tag' dest_dirs.each do |dir| dest_path << "/#{dir}" self.mkdir('-m', "'#{Constants::ME}: creating #{branch_or_tag} path #{dest_path}'", dest_path) unless self.has_path(dest_path) end self.copy('-m', "'#{Constants::ME}: creating #{branch_or_tag} #{relative_dest}'", '-r', configuration[:revision], source, dest) end |
.current_revision(path) ⇒ Object
get the current revision number from the given path
63 64 65 66 67 68 69 70 71 |
# File 'lib/svnauto/svn.rb', line 63 def self.current_revision (path) rev = nil Svn.info(path) do |line| m = line.match(/^Revision:\s+(\d+)$/) and rev = m[1].to_i end rev end |
.has_path(path) ⇒ Object
Check to see if the given path exists in the repository
53 54 55 56 57 58 59 |
# File 'lib/svnauto/svn.rb', line 53 def self.has_path (path) self.list(path) do |line| return false if line.match(/^svn:/) end true end |