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
- #commit_identifier(sha1) ⇒ Object
- #commit_metadata(sha1) ⇒ Object
-
#initialize(uri, branch, working_directory) ⇒ Git
constructor
A new instance of Git.
- #name ⇒ Object
- #with_revision(revision) ⇒ Object
Constructor Details
#initialize(uri, branch, working_directory) ⇒ 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) @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
#commit_identifier(sha1) ⇒ Object
24 25 26 |
# File 'lib/integrity/scm/git.rb', line 24 def commit_identifier(sha1) `cd #{working_directory} && git show -s --pretty=format:%H #{sha1}`.chomp end |
#commit_metadata(sha1) ⇒ Object
28 29 30 31 |
# File 'lib/integrity/scm/git.rb', line 28 def (sha1) format = %Q(---%n:author: %an <%ae>%n:message: >-%n %s%n:date: %ci%n) YAML.load(`cd #{working_directory} && git show -s --pretty=format:"#{format}" #{sha1}`) end |
#name ⇒ Object
33 34 35 |
# File 'lib/integrity/scm/git.rb', line 33 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 |