diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-12 11:50:14 +0200 |
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-12 11:50:14 +0200 |
| commit | f2834177c0fdf6b1af659e460fd3348f468b8ab0 (patch) | |
| tree | 2cb12187e664a026974383ed303cf307df2d4029 /lib/git/objects/tag.py | |
| parent | 3c0a65226f038c58fc6d6ed525f38fc00b3579b7 (diff) | |
| download | GitPython-f2834177c0fdf6b1af659e460fd3348f468b8ab0.tar.gz GitPython-f2834177c0fdf6b1af659e460fd3348f468b8ab0.zip | |
Reorganized package structure and cleaned up imports
Diffstat (limited to 'lib/git/objects/tag.py')
| -rw-r--r-- | lib/git/objects/tag.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/lib/git/objects/tag.py b/lib/git/objects/tag.py new file mode 100644 index 00000000..af1022f0 --- /dev/null +++ b/lib/git/objects/tag.py @@ -0,0 +1,71 @@ +# objects.py +# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors +# +# This module is part of GitPython and is released under +# the BSD License: http://www.opensource.org/licenses/bsd-license.php +""" +Module containing all object based types. +""" +import base +import commit +from util import get_object_type_by_name + +class TagObject(base.Object): + """ + Non-Lightweight tag carrying additional information about an object we are pointing + to. + """ + type = "tag" + __slots__ = ( "object", "tag", "tagger", "tagged_date", "message" ) + + def __init__(self, repo, id, object=None, tag=None, + tagger=None, tagged_date=None, message=None): + """ + Initialize a tag object with additional data + + ``repo`` + repository this object is located in + + ``id`` + SHA1 or ref suitable for git-rev-parse + + ``object`` + Object instance of object we are pointing to + + ``tag`` + name of this tag + + ``tagger`` + Actor identifying the tagger + + ``tagged_date`` : (tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst) + is the DateTime of the tag creation + """ + super(TagObject, self).__init__(repo, id ) + self._set_self_from_args_(locals()) + + def _set_cache_(self, attr): + """ + Cache all our attributes at once + """ + if attr in self.__slots__: + output = self.repo.git.cat_file(self.type,self.id) + lines = output.split("\n") + + obj, hexsha = lines[0].split(" ") # object <hexsha> + type_token, type_name = lines[1].split(" ") # type <type_name> + self.object = get_object_type_by_name(type_name)(self.repo, hexsha) + + self.tag = lines[2][4:] # tag <tag name> + + tagger_info = lines[3][7:]# tagger <actor> <date> + self.tagger, self.tagged_date = commit.Commit._actor(tagger_info) + + # line 4 empty - check git source to figure out purpose + self.message = "\n".join(lines[5:]) + # END check our attributes + else: + super(TagObject, self)._set_cache_(attr) + + + |
