Class: Vendorificator::Commit
- Inherits:
-
Object
- Object
- Vendorificator::Commit
- Defined in:
- lib/vendorificator/commit.rb
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#rev ⇒ Object
readonly
Returns the value of attribute rev.
Instance Method Summary collapse
-
#branches ⇒ Object
Public: Finds branches that contain this commit.
-
#exists? ⇒ Boolean
Public: Checks if such a commit exists in the repository.
-
#initialize(rev, git) ⇒ Commit
constructor
Public: Initializes the object.
-
#notes ⇒ Object
Public: Returns vendorificator git notes for the commit.
-
#notes? ⇒ Boolean
Public: Returns vendorificator git notes for the commit if it exists.
Constructor Details
#initialize(rev, git) ⇒ Commit
Public: Initializes the object
rev - The String containing revision expression for this commit. git - The MiniGit instance to use.
Returns Commit object.
13 14 15 16 |
# File 'lib/vendorificator/commit.rb', line 13 def initialize(rev, git) @rev = rev @git = git end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
5 6 7 |
# File 'lib/vendorificator/commit.rb', line 5 def git @git end |
#rev ⇒ Object (readonly)
Returns the value of attribute rev.
5 6 7 |
# File 'lib/vendorificator/commit.rb', line 5 def rev @rev end |
Instance Method Details
#branches ⇒ Object
Public: Finds branches that contain this commit.
Returns Array of branch names.
21 22 23 24 25 |
# File 'lib/vendorificator/commit.rb', line 21 def branches git.capturing.branch({:contains => true}, rev).split("\n").map do |name| name.tr('*', '').strip end end |
#exists? ⇒ Boolean
Public: Checks if such a commit exists in the repository.
Returns Boolean.
30 31 32 33 34 35 |
# File 'lib/vendorificator/commit.rb', line 30 def exists? git.capturing.rev_parse rev true rescue MiniGit::GitError false end |
#notes ⇒ Object
Public: Returns vendorificator git notes for the commit.
Returns the notes Hash.
40 41 42 |
# File 'lib/vendorificator/commit.rb', line 40 def notes YAML.load(git.capturing.notes({:ref => 'vendor'}, 'show', rev)) end |
#notes? ⇒ Boolean
Public: Returns vendorificator git notes for the commit if it exists.
Returns the notes Hash or an empty one.
47 48 49 50 51 52 53 |
# File 'lib/vendorificator/commit.rb', line 47 def notes? if exists? YAML.load(git.capturing.notes({:ref => 'vendor'}, 'show', rev)) else {} end end |