Class: BuildTool::VCS::Svn
Overview
Implementation for the subversion version control system.
Defined Under Namespace
Classes: SvnError
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .svn(command, wd, &block) ⇒ Object
-
.svn_available? ⇒ Boolean
Is the git executable available?.
Instance Method Summary collapse
- #[](var) ⇒ Object
- #[]=(var, val) ⇒ Object
-
#checkedout? ⇒ Boolean
METHODS.
-
#clone ⇒ Object
Initialize the local repository.
- #fetch(verbose = false) ⇒ Object
- #fetching_supported? ⇒ Boolean
-
#last_changed_rev ⇒ Object
Returns the last changed revision on the remote repository.
-
#name ⇒ Object
ATTRIBUTES.
- #prepare_for_fetch ⇒ Object
- #ready_for_fetch ⇒ Object
- #rebase(verbose = false) ⇒ Object
- #remote_path ⇒ Object
- #repository ⇒ Object
-
#svn(command, wd = local_path, &block) ⇒ Object
Call svn with command.
Methods inherited from Base
#apply_patches_after_rebase?, #check_for_sshkey, #configure, #gc, #initialize, #local_path, #local_path_exist?, #patches_supported?, #prepare_for_rebase, #ready_for_rebase, #recipe
Constructor Details
This class inherits a constructor from BuildTool::VCS::Base
Class Method Details
.svn(command, wd, &block) ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/build-tool/vcs/svn.rb', line 185 def self.svn( command, wd, &block ) rc = self.execute( "svn " + command, wd, &block ) if rc != 0 raise SvnError, "Command 'svn #{command}' failed with error code #{rc}!" end rc end |
.svn_available? ⇒ Boolean
Is the git executable available?
69 70 71 72 73 74 |
# File 'lib/build-tool/vcs/svn.rb', line 69 def svn_available? return @svn_available unless @svn_available.nil? %x( svn --version 2>&1 ) @svn_available = $?.success? return @svn_available end |
Instance Method Details
#[](var) ⇒ Object
198 199 200 201 202 203 204 205 206 207 |
# File 'lib/build-tool/vcs/svn.rb', line 198 def[]( var ) case var when nil else # *TODO* raise correct exception raise NotImplementedError, "#{var}" end end |
#[]=(var, val) ⇒ Object
209 210 211 212 213 214 215 216 217 218 |
# File 'lib/build-tool/vcs/svn.rb', line 209 def[]=( var, val ) case var when nil else # *TODO* raise correct exception raise NotImplementedError, "#{var}" end end |
#checkedout? ⇒ Boolean
METHODS
95 96 97 98 99 100 101 102 |
# File 'lib/build-tool/vcs/svn.rb', line 95 def checkedout? return false if !local_path_exist? if !File.exists? "#{local_path}/.svn" logger.debug("Checkout path #{local_path} is not a svn repo") return false end return true end |
#clone ⇒ Object
Initialize the local repository
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/build-tool/vcs/svn.rb', line 105 def clone # Check if local_path exists if local_path_exist? raise SvnError, "Failed to create repository at '#{local_path}': Path exists" end # Create the directories parent dir. FileUtils.mkdir_p( File.dirname( local_path ) ) if !$noop # Init the repository if config.only svn "checkout --depth=files #{repository.url}/#{remote_path} #{local_path}", local_path.dirname config.only.each do |elem| svn "update --depth=infinity #{elem}", local_path end else svn "checkout --depth=infinity #{repository.url}/#{remote_path} #{local_path}", local_path.dirname end return true end |
#fetch(verbose = false) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/build-tool/vcs/svn.rb', line 134 def fetch( verbose = false ) if !checkedout? return clone end if verbose svn "log -r HEAD:BASE -q" do |line| logger.info( line ) end end svn "update" return true end |
#fetching_supported? ⇒ Boolean
86 87 88 |
# File 'lib/build-tool/vcs/svn.rb', line 86 def fetching_supported? false end |
#last_changed_rev ⇒ Object
Returns the last changed revision on the remote repository. Return 0 if the last changed revision could not be determined.
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/build-tool/vcs/svn.rb', line 153 def last_changed_rev info = Hash.new svn( "info #{repository.url}/#{remote_path}", nil ) { |line| key, value = line.chomp.split( ':', 2 ) info[key] = value } return 777777 if $noop version = info["Last Changed Rev"]; raise SvnError, "Failed to determine revision for #{repository.url}/#{remote_path}" if version.nil? return version end |
#name ⇒ Object
ATTRIBUTES
82 83 84 |
# File 'lib/build-tool/vcs/svn.rb', line 82 def name "svn" end |
#prepare_for_fetch ⇒ Object
166 167 168 169 |
# File 'lib/build-tool/vcs/svn.rb', line 166 def prepare_for_fetch # If our server has an associated ssh-key, add it to the ssh-agent. return check_for_sshkey( config.repository.sshkey ) end |
#ready_for_fetch ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/build-tool/vcs/svn.rb', line 126 def ready_for_fetch if not Svn.svn_available? logger.info( "#{config.module.name}: Calling `svn` failed!" ) return false end return true end |
#rebase(verbose = false) ⇒ Object
193 194 195 196 |
# File 'lib/build-tool/vcs/svn.rb', line 193 def rebase( verbose = false ) # Rebasing is not supported 0 end |
#remote_path ⇒ Object
171 172 173 |
# File 'lib/build-tool/vcs/svn.rb', line 171 def remote_path @config.remote_path end |
#repository ⇒ Object
175 176 177 |
# File 'lib/build-tool/vcs/svn.rb', line 175 def repository config.repository end |
#svn(command, wd = local_path, &block) ⇒ Object
Call svn with command
181 182 183 |
# File 'lib/build-tool/vcs/svn.rb', line 181 def svn( command, wd = local_path, &block ) self.class.svn( command, wd, &block ) end |