Class: Integrity::SCM::Git

Inherits:
Object show all
Defined in:
lib/integrity/scm/git.rb,
lib/integrity/scm/git/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) ⇒ Git

Returns a new instance of Git.



12
13
14
15
16
# File 'lib/integrity/scm/git.rb', line 12

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.



6
7
8
# File 'lib/integrity/scm/git.rb', line 6

def branch
  @branch
end

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/integrity/scm/git.rb', line 6

def uri
  @uri
end

#working_directoryObject (readonly)

Returns the value of attribute working_directory.



6
7
8
# File 'lib/integrity/scm/git.rb', line 6

def working_directory
  @working_directory
end

Class Method Details

.working_tree_path(uri) ⇒ Object



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

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

Instance Method Details

#headObject



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

def head
  log "Getting the HEAD of '#{uri}' at '#{branch}'"
  `git ls-remote --heads #{uri} #{branch} | awk '{print $1}'`.chomp
end

#info(revision) ⇒ Object



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

def info(revision)
  format  = %Q(---%n:author: %an <%ae>%n:message: >-%n  %s%n:committed_at: %ci%n)
  YAML.load(`cd #{working_directory} && git show -s --pretty=format:"#{format}" #{revision}`)
end

#nameObject



24
25
26
# File 'lib/integrity/scm/git.rb', line 24

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

#with_revision(revision) ⇒ Object



18
19
20
21
22
# File 'lib/integrity/scm/git.rb', line 18

def with_revision(revision)
  fetch_code
  checkout(revision)
  yield
end