def self.from_raw(rawobject, repository=nil)
headers, message = rawobject.content.split(/\n\n/, 2)
headers = headers.split(/\n/).map { |header| header.split(/ /, 2) }
headers.each do |key, value|
case key
when "object"
object = value
when "type"
if !["blob", "tree", "commit", "tag"].include?(value)
raise RuntimeError, "invalid type in tag"
end
type = value.to_sym
when "tag"
tag = value
when "tagger"
tagger = UserInfo.new(value)
else
warn "unknown header '%s' in tag" % \
[key, rawobject.sha1.unpack("H*")[0]]
end
if not object && type && tag && tagger
raise RuntimeError, "incomplete raw tag object"
end
end
new(object, type, tag, tagger, repository)
end