Class: Subversion
- Inherits:
-
Object
- Object
- Subversion
- Defined in:
- lib/chef-deploy/subversion.rb
Instance Method Summary collapse
-
#checkout(revision, destination) ⇒ Object
Returns the command that will check out the given revision to the given destination.
- #config ⇒ Object
-
#diff(from, to = nil) ⇒ Object
Returns the command that will do an “svn diff” for the two revisions.
-
#export(revision, destination) ⇒ Object
Returns the command that will do an “svn export” of the given revision to the given destination.
-
#head ⇒ Object
Subversion understands ‘HEAD’ to refer to the latest revision in the repository.
-
#initialize(opts = {}) ⇒ Subversion
constructor
A new instance of Subversion.
-
#log(from, to = nil) ⇒ Object
Returns an “svn log” command for the two revisions.
-
#next_revision(revision) ⇒ Object
Increments the given revision number and returns it.
-
#query_revision(revision) ⇒ Object
Attempts to translate the given revision identifier to a “real” revision.
- #repository ⇒ Object
-
#sync(revision, destination) ⇒ Object
Returns the command that will do an “svn update” to the given revision, for the working copy at the given destination.
Constructor Details
#initialize(opts = {}) ⇒ Subversion
Returns a new instance of Subversion.
5 6 7 |
# File 'lib/chef-deploy/subversion.rb', line 5 def initialize(opts={}) @config = opts end |
Instance Method Details
#checkout(revision, destination) ⇒ Object
Returns the command that will check out the given revision to the given destination.
25 26 27 |
# File 'lib/chef-deploy/subversion.rb', line 25 def checkout(revision, destination) scm :checkout, config[:arguments], verbose, authentication, "-r#{revision}", repository, destination end |
#config ⇒ Object
9 10 11 |
# File 'lib/chef-deploy/subversion.rb', line 9 def config @config end |
#diff(from, to = nil) ⇒ Object
Returns the command that will do an “svn diff” for the two revisions.
42 43 44 |
# File 'lib/chef-deploy/subversion.rb', line 42 def diff(from, to=nil) scm :diff, repository, authentication, "-r#{from}:#{to || head}" end |
#export(revision, destination) ⇒ Object
Returns the command that will do an “svn export” of the given revision to the given destination.
37 38 39 |
# File 'lib/chef-deploy/subversion.rb', line 37 def export(revision, destination) scm :export, config[:arguments], verbose, authentication, "-r#{revision}", repository, destination end |
#head ⇒ Object
Subversion understands ‘HEAD’ to refer to the latest revision in the repository.
15 16 17 |
# File 'lib/chef-deploy/subversion.rb', line 15 def head "HEAD" end |
#log(from, to = nil) ⇒ Object
Returns an “svn log” command for the two revisions.
47 48 49 |
# File 'lib/chef-deploy/subversion.rb', line 47 def log(from, to=nil) scm :log, repository, authentication, "-r#{from}:#{to || head}" end |
#next_revision(revision) ⇒ Object
Increments the given revision number and returns it.
65 66 67 |
# File 'lib/chef-deploy/subversion.rb', line 65 def next_revision(revision) revision.to_i + 1 end |
#query_revision(revision) ⇒ Object
Attempts to translate the given revision identifier to a “real” revision. If the identifier is an integer, it will simply be returned. Otherwise, this will yield a string of the commands it needs to be executed (svn info), and will extract the revision from the response.
55 56 57 58 59 60 61 62 |
# File 'lib/chef-deploy/subversion.rb', line 55 def query_revision(revision) return revision if revision =~ /^\d+$/ command = scm(:info, repository, authentication, "-r#{revision}") result = yield(command) yaml = YAML.load(result) raise "tried to run `#{command}' and got unexpected result #{result.inspect}" unless Hash === yaml yaml['Last Changed Rev'] || yaml['Revision'] end |
#repository ⇒ Object
19 20 21 |
# File 'lib/chef-deploy/subversion.rb', line 19 def repository config[:repository] end |
#sync(revision, destination) ⇒ Object
Returns the command that will do an “svn update” to the given revision, for the working copy at the given destination.
31 32 33 |
# File 'lib/chef-deploy/subversion.rb', line 31 def sync(revision, destination) scm :update, config[:arguments], verbose, authentication, "-r#{revision}", destination end |