Class: Grit::Tag
Instance Attribute Summary
Attributes inherited from Ref
Class Method Summary collapse
- .find_all(repo, options = {}) ⇒ Object
-
.parse_tag_data(data) ⇒ Object
Parses the results from ‘cat-file -p`.
Instance Method Summary collapse
Methods included from Lazy
Methods inherited from Ref
Constructor Details
This class inherits a constructor from Grit::Ref
Class Method Details
.find_all(repo, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/grit/tag.rb', line 10 def self.find_all(repo, = {}) refs = repo.git.refs(, prefix) refs.split("\n").map do |ref| name, id = *ref.split(' ') sha = repo.git.commit_from_sha(id) raise "Unknown object type." if sha == '' commit = Commit.create(repo, :id => sha) new(name, commit) end end |
.parse_tag_data(data) ⇒ Object
Parses the results from ‘cat-file -p`
data - String tag object data. Example:
object 7bcc0ee821cdd133d8a53e8e7173a334fef448aa
type commit
tag v0.7.0
tagger USER <EMAIL> DATE
v0.7.0
Returns parsed Hash. Example:
{:message => "...", :tagger => "bob", :tag_date => ...}
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/grit/tag.rb', line 33 def self.parse_tag_data(data) return unless data =~ /^object/ parsed = {} lines = data.split("\n") lines.shift # type commit lines.shift # tag name lines.shift = lines.shift parsed[:tagger], parsed[:tag_date] = Commit.actor() if !parsed[:tagger] || !parsed[:tagger].name parsed[:tag_date] ||= Time.utc(1970) parsed[:tagger] = Actor.from_string(.sub(/^tagger /, '')) end lines.shift # blank line parsed[:message] = [] while lines.first && lines.first !~ /-----BEGIN PGP SIGNATURE-----/ parsed[:message] << lines.shift end parsed[:message] = parsed[:message] * "\n" parsed end |
Instance Method Details
#lazy_source ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/grit/tag.rb', line 55 def lazy_source data = commit.repo.git.cat_ref({:p => true}, name) @message = commit. @tagger = commit. @tag_date = commit. return self if data.empty? if parsed = self.class.parse_tag_data(data) @message = parsed[:message] @tagger = parsed[:tagger] @tag_date = parsed[:tag_date] end self end |