Class: Integrity::SCM::Git
- Defined in:
- lib/integrity/scm/git.rb,
lib/integrity/scm/git/uri.rb
Defined Under Namespace
Classes: URI
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#working_directory ⇒ Object
readonly
Returns the value of attribute working_directory.
Class Method Summary collapse
Instance Method Summary collapse
- #head ⇒ Object
- #info(revision) ⇒ Object
-
#initialize(uri, branch, working_directory = nil) ⇒ Git
constructor
A new instance of Git.
- #name ⇒ Object
- #with_revision(revision) ⇒ Object
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
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
6 7 8 |
# File 'lib/integrity/scm/git.rb', line 6 def branch @branch end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/integrity/scm/git.rb', line 6 def uri @uri end |
#working_directory ⇒ Object (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
#head ⇒ Object
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 |
#name ⇒ Object
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 |