Class Grit::GitRuby::Tag
In: lib/grit/git-ruby/git_object.rb
lib/grit/git-ruby/object.rb
Parent: GitObject

Methods

from_raw   from_raw   new   new   raw_content   raw_content   type   type  

Attributes

message  [RW] 
message  [RW] 
object  [RW] 
object  [RW] 
tag  [RW] 
tag  [RW] 
tagger  [RW] 
tagger  [RW] 
type  [RW] 
type  [RW] 

Public Class methods

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 295
295:     def self.from_raw(rawobject, repository=nil)
296:       
297:       headers, message = rawobject.content.split(/\n\n/, 2)
298:       headers = headers.split(/\n/).map { |header| header.split(' ', 2) }
299:       
300:       object = ''
301:       type = ''
302:       tag = ''
303:       tagger = ''
304:       
305:       headers.each do |key, value|
306:         case key
307:         when "object"
308:           object = value
309:         when "type"
310:           if !["blob", "tree", "commit", "tag"].include?(value)
311:             raise RuntimeError, "invalid type in tag"
312:           end
313:           type = value.to_sym
314:         when "tag"
315:           tag = value
316:         when "tagger"
317:           tagger = UserInfo.new(value)
318:         else
319:           warn "unknown header '%s' in tag" % \
320:             [key, rawobject.sha1.unpack("H*")[0]]
321:         end
322:       end
323: 
324:       if not object && type && tag && tagger
325:         raise RuntimeError, "incomplete raw tag object"
326:       end
327:       new(object, type, tag, tagger, message, repository)
328:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 279
279:     def self.from_raw(rawobject, repository=nil)
280:       headers, message = rawobject.content.split(/\n\n/, 2)
281:       headers = headers.split(/\n/).map { |header| header.split(/ /, 2) }
282:       headers.each do |key, value|
283:         case key
284:         when "object"
285:           object = value
286:         when "type"
287:           if !["blob", "tree", "commit", "tag"].include?(value)
288:             raise RuntimeError, "invalid type in tag"
289:           end
290:           type = value.to_sym
291:         when "tag"
292:           tag = value
293:         when "tagger"
294:           tagger = UserInfo.new(value)
295:         else
296:           warn "unknown header '%s' in tag" % \
297:             [key, rawobject.sha1.unpack("H*")[0]]
298:         end
299:         if not object && type && tag && tagger
300:           raise RuntimeError, "incomplete raw tag object"
301:         end
302:       end
303:       new(object, type, tag, tagger, repository)
304:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 306
306:     def initialize(object, type, tag, tagger, repository=nil)
307:       @object = object
308:       @type = type
309:       @tag = tag
310:       @tagger = tagger
311:       @repository = repository
312:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 330
330:     def initialize(object, type, tag, tagger, message, repository=nil)
331:       @object = object
332:       @type = type
333:       @tag = tag
334:       @tagger = tagger
335:       @repository = repository
336:       @message = message
337:     end

Public Instance methods

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 339
339:     def raw_content
340:       "object %s\ntype %s\ntag %s\ntagger %s\n\n" % \
341:         [@object, @type, @tag, @tagger] + @message
342:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 314
314:     def raw_content
315:       "object %s\ntype %s\ntag %s\ntagger %s\n\n" % \
316:         [@object, @type, @tag, @tagger] + @message
317:     end

[Source]

     # File lib/grit/git-ruby/git_object.rb, line 344
344:     def type
345:       :tag
346:     end

[Source]

     # File lib/grit/git-ruby/object.rb, line 319
319:     def type
320:       :tag
321:     end

[Validate]