Class: Grit::Head
Overview
A Head is a named reference to a Commit. Every Head instance contains a name and a Commit object.
r = Grit::Repo.new("/path/to/repo")
h = r.heads.first
h.name # => "master"
h.commit # => #<Grit::Commit "1c09f116cbc2cb4100fb6935bb162daa4723f455">
h.commit.id # => "1c09f116cbc2cb4100fb6935bb162daa4723f455"
Instance Attribute Summary
Attributes inherited from Ref
Class Method Summary collapse
-
.current(repo, options = {}) ⇒ Object
Get the HEAD revision of the repo.
Methods inherited from Ref
#commit, count_all, find_all, #initialize, #inspect
Constructor Details
This class inherits a constructor from Grit::Ref
Class Method Details
.current(repo, options = {}) ⇒ Object
Get the HEAD revision of the repo.
+repo+ is the Repo
+options+ is a Hash of options
Returns Grit::Head (baked)
84 85 86 87 88 89 90 |
# File 'lib/grit/ref.rb', line 84 def self.current(repo, = {}) head = repo.git.fs_read('HEAD').chomp if /ref: refs\/heads\/(.*)/.match(head) id = repo.git.rev_parse(, 'HEAD') self.new($1, repo, id) end end |