From 907b03949bab53e2f7d55094100a71abd22f23e7 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Sun, 11 Nov 2007 16:01:23 -0800 Subject: added tagging --- lib/git/object.rb | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'lib/git/object.rb') diff --git a/lib/git/object.rb b/lib/git/object.rb index f100597..a7d7c17 100644 --- a/lib/git/object.rb +++ b/lib/git/object.rb @@ -1,4 +1,8 @@ module Git + + class GitTagNameDoesNotExist< StandardError + end + class Object class AbstractObject @@ -64,14 +68,34 @@ module Git end end - + class Tag < AbstractObject + attr_accessor :name + + def initialize(base, sha, name) + super(base, sha) + @name = name + end + + def setup + @type = 'tag' + end + end + class << self # if we're calling this, we don't know what type it is yet # so this is our little factory method - def new(base, objectish) - sha = base.lib.revparse(objectish) - type = base.lib.object_type(sha) - + def new(base, objectish, is_tag = false) + if is_tag + sha = base.lib.tag_sha(objectish) + if sha == '' + raise Git::GitTagNameDoesNotExist.new(objectish) + end + return Tag.new(base, sha, objectish) + else + sha = base.lib.revparse(objectish) + type = base.lib.object_type(sha) + end + klass = case type when /blob/: Blob -- cgit