summaryrefslogtreecommitdiffstats
path: root/lib/git/object.rb
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 16:01:23 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-11 16:01:23 -0800
commit907b03949bab53e2f7d55094100a71abd22f23e7 (patch)
tree51b7fca355ac7007957d966cbebbcbf331c57d7d /lib/git/object.rb
parentb81ee9305f418209ba0d77fbb7b47b23d4b121ca (diff)
downloadthird_party-ruby-git-907b03949bab53e2f7d55094100a71abd22f23e7.tar.gz
third_party-ruby-git-907b03949bab53e2f7d55094100a71abd22f23e7.tar.xz
third_party-ruby-git-907b03949bab53e2f7d55094100a71abd22f23e7.zip
added tagging
Diffstat (limited to 'lib/git/object.rb')
-rw-r--r--lib/git/object.rb34
1 files changed, 29 insertions, 5 deletions
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