Class | Grit::Ref |
In: |
lib/grit/ref.rb
|
Parent: | Object |
commit | [R] | |
name | [R] |
Find all Refs
+repo+ is the Repo +options+ is a Hash of options
Returns Grit::Ref[] (baked)
# File lib/grit/ref.rb, line 12 def find_all(repo, options = {}) refs = [] already = {} Dir.chdir(repo.path) do files = Dir.glob(prefix + '/**/*') files.each do |ref| next if !File.file?(ref) id = File.read(ref).chomp name = ref.sub("#{prefix}/", '') commit = Commit.create(repo, :id => id) if !already[name] refs << self.new(name, commit) already[name] = true end end if File.file?('packed-refs') File.readlines('packed-refs').each do |line| if m = /^(\w{40}) (.*?)$/.match(line) next if !Regexp.new('^' + prefix).match(m[2]) name = m[2].sub("#{prefix}/", '') commit = Commit.create(repo, :id => m[1]) if !already[name] refs << self.new(name, commit) already[name] = true end end end end end refs end
+name+ is the name of the head +commit+ is the Commit that the head points to
Returns Grit::Head (baked)
# File lib/grit/ref.rb, line 62 def initialize(name, commit) @name = name @commit = commit end