Class Grit::Head
In: lib/grit/ref.rb
Parent: Ref

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"

Methods

current  

Public Class methods

Get the HEAD revision of the repo.

  +repo+ is the Repo
  +options+ is a Hash of options

Returns Grit::Head (baked)

[Source]

    # File lib/grit/ref.rb, line 88
88:     def self.current(repo, options = {})
89:       head = File.open(File.join(repo.path, 'HEAD')).read.chomp
90:       if /ref: refs\/heads\/(.*)/.match(head)
91:         self.new($1, repo.git.rev_parse(options, 'HEAD'))
92:       end
93:     end

[Validate]