Class: Integrity::SCM::Subversion

Inherits:
Object
  • Object
show all
Defined in:
lib/integrity/scm/subversion.rb,
lib/integrity/scm/subversion/uri.rb

Defined Under Namespace

Classes: URI

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, branch, working_directory = nil) ⇒ Subversion

Returns a new instance of Subversion.



21
22
23
24
25
# File 'lib/integrity/scm/subversion.rb', line 21

def initialize(uri, branch, working_directory = nil)
  @uri = uri.to_s
  @branch = branch.to_s
  @working_directory = working_directory
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



8
9
10
# File 'lib/integrity/scm/subversion.rb', line 8

def branch
  @branch
end

#uriObject (readonly)

Returns the value of attribute uri.



8
9
10
# File 'lib/integrity/scm/subversion.rb', line 8

def uri
  @uri
end

#working_directoryObject (readonly)

Returns the value of attribute working_directory.



8
9
10
# File 'lib/integrity/scm/subversion.rb', line 8

def working_directory
  @working_directory
end

Class Method Details

.is_this_my_home?(location) ⇒ Boolean

check the uri and see if it is a subversion url There is a lot that can be a subversion url

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/integrity/scm/subversion.rb', line 16

def self.is_this_my_home?( location )
  uri = Addressable::URI.parse( location )
  %w[ svn+ssh svn http https file ].include?( uri.scheme )
end

.working_tree_path(uri) ⇒ Object



10
11
12
# File 'lib/integrity/scm/subversion.rb', line 10

def self.working_tree_path(uri)
  Subversion::URI.new( uri ).working_tree_path
end

Instance Method Details

#headObject



37
38
39
40
41
42
# File 'lib/integrity/scm/subversion.rb', line 37

def head
  log "Getting the HEAD of '#{uri}'"
  xml = %x[ svn info --non-interactive --xml #{uri} ]
  doc = Hpricot::XML( xml )
  return doc.at("commit")['revision']
end

#info(revision) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/integrity/scm/subversion.rb', line 44

def info( revision )
  log "Retrieving info for revision #{revision}"
  xml = %x[  svn log --non-interactive --xml --revision #{revision} #{uri} ]
  doc = Hpricot::XML( xml )
  h = {}
  h['author']       = doc.at('author').inner_html + " <noemail>"
  h['message']      = doc.at('msg').inner_html
  h['committed_at'] = Time.parse(doc.at('date').inner_html).iso8601
  return h
end

#nameObject



33
34
35
# File 'lib/integrity/scm/subversion.rb', line 33

def name
  self.class.name.split("::").last
end

#with_revision(revision) ⇒ Object



27
28
29
30
31
# File 'lib/integrity/scm/subversion.rb', line 27

def with_revision(revision)
  initial_checkout unless already_out?
  update_to(revision)
  yield
end