Class: Grit::Ref
- Inherits:
-
Object
- Object
- Grit::Ref
- Defined in:
- lib/grit/ref.rb
Instance Attribute Summary collapse
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.find_all(repo, options = {}) ⇒ Object
Find all Refs
repo
is the Repooptions
is a Hash of options.
Instance Method Summary collapse
-
#initialize(name, commit) ⇒ Ref
constructor
Instantiate a new Head
name
is the name of the headcommit
is the Commit that the head points to. -
#inspect ⇒ Object
Pretty object inspection.
Constructor Details
#initialize(name, commit) ⇒ Ref
Instantiate a new Head
+name+ is the name of the head
+commit+ is the Commit that the head points to
Returns Grit::Head (baked)
62 63 64 65 |
# File 'lib/grit/ref.rb', line 62 def initialize(name, commit) @name = name @commit = commit end |
Instance Attribute Details
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
55 56 57 |
# File 'lib/grit/ref.rb', line 55 def commit @commit end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
54 55 56 |
# File 'lib/grit/ref.rb', line 54 def name @name end |
Class Method Details
.find_all(repo, options = {}) ⇒ Object
Find all Refs
+repo+ is the Repo
+options+ is a Hash of options
Returns Grit::Ref[] (baked)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/grit/ref.rb', line 12 def find_all(repo, = {}) 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 |
Instance Method Details
#inspect ⇒ Object
Pretty object inspection
68 69 70 |
# File 'lib/grit/ref.rb', line 68 def inspect %Q{#<#{self.class.name} "#{@name}">} end |