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

Methods

find_all   inspect   new   prefix  

Attributes

commit  [R] 
name  [R] 

Public Class methods

Find all Refs

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

Returns Grit::Ref[] (baked)

[Source]

# 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

Instantiate a new Head

  +name+ is the name of the head
  +commit+ is the Commit that the head points to

Returns Grit::Head (baked)

[Source]

# File lib/grit/ref.rb, line 62
    def initialize(name, commit)
      @name = name
      @commit = commit
    end

Protected Class methods

[Source]

# File lib/grit/ref.rb, line 48
        def prefix
          "refs/#{name.to_s.gsub(/^.*::/, '').downcase}s"
        end

Public Instance methods

Pretty object inspection

[Source]

# File lib/grit/ref.rb, line 68
    def inspect
      %Q{#<#{self.class.name} "#{@name}">}
    end

[Validate]