diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-06-28 19:15:42 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-06-28 19:15:54 +0200 |
commit | 1fe889ea0cb2547584075dc1eb77f52c54b9a8c4 (patch) | |
tree | cd3685e0bd87441eab4888efbc4e14a232a65a7b /lib/git/objects | |
parent | 47e3138ee978ce708a41f38a0d874376d7ae5c78 (diff) | |
download | gitpython-1fe889ea0cb2547584075dc1eb77f52c54b9a8c4.tar.gz |
All tests adjusted to work with the changed internal sha representation
Diffstat (limited to 'lib/git/objects')
-rw-r--r-- | lib/git/objects/blob.py | 24 | ||||
-rw-r--r-- | lib/git/objects/commit.py | 19 | ||||
-rw-r--r-- | lib/git/objects/tag.py | 2 | ||||
-rw-r--r-- | lib/git/objects/tree.py | 9 |
4 files changed, 29 insertions, 25 deletions
diff --git a/lib/git/objects/blob.py b/lib/git/objects/blob.py index ed7a8d04..8263e9a2 100644 --- a/lib/git/objects/blob.py +++ b/lib/git/objects/blob.py @@ -10,11 +10,11 @@ import base __all__ = ('Blob', ) class Blob(base.IndexObject): - """A Blob encapsulates a git blob object""" - DEFAULT_MIME_TYPE = "text/plain" - type = "blob" + """A Blob encapsulates a git blob object""" + DEFAULT_MIME_TYPE = "text/plain" + type = "blob" - __slots__ = "data" + __slots__ = "data" def _set_cache_(self, attr): if attr == "data": @@ -26,11 +26,11 @@ class Blob(base.IndexObject): super(Blob, self)._set_cache_(attr) # END handle data - @property - def mime_type(self): - """ :return:String describing the mime type of this file (based on the filename) - :note: Defaults to 'text/plain' in case the actual file type is unknown. """ - guesses = None - if self.path: - guesses = guess_type(self.path) - return guesses and guesses[0] or self.DEFAULT_MIME_TYPE + @property + def mime_type(self): + """ :return:String describing the mime type of this file (based on the filename) + :note: Defaults to 'text/plain' in case the actual file type is unknown. """ + guesses = None + if self.path: + guesses = guess_type(self.path) + return guesses and guesses[0] or self.DEFAULT_MIME_TYPE diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py index 3bf1fbc4..f365c994 100644 --- a/lib/git/objects/commit.py +++ b/lib/git/objects/commit.py @@ -23,13 +23,14 @@ from utils import ( get_user_id, parse_date, Actor, - altz_to_utctz_str + altz_to_utctz_str, parse_actor_and_date ) from time import ( time, altzone ) +import os __all__ = ('Commit', ) @@ -76,7 +77,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): :param parents: tuple( Commit, ... ) is a tuple of commit ids or actual Commits :param tree: Tree - 20 byte tree sha + Tree object :param author: Actor is the author string ( will be implicitly converted into an Actor object ) :param authored_date: int_seconds_since_epoch @@ -103,7 +104,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): :note: Timezone information is in the same format and in the same sign as what time.altzone returns. The sign is inverted compared to git's UTC timezone.""" - super(Commit,self).__init__(repo, sha) + super(Commit,self).__init__(repo, binsha) self._set_self_from_args_(locals()) @classmethod @@ -227,14 +228,14 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): line = readline() if not line: break - sha = line.strip() - if len(sha) > 40: + hexsha = line.strip() + if len(hexsha) > 40: # split additional information, as returned by bisect for instance - sha, rest = line.split(None, 1) + hexsha, rest = line.split(None, 1) # END handle extra info - assert len(sha) == 40, "Invalid line: %s" % sha - yield Commit(repo, sha) + assert len(hexsha) == 40, "Invalid line: %s" % hexsha + yield Commit(repo, hex_to_bin(hexsha)) # END for each line in stream @@ -282,7 +283,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): # COMMITER AND AUTHOR INFO cr = repo.config_reader() - env = environ + env = os.environ default_email = get_user_id() default_name = default_email.split('@')[0] diff --git a/lib/git/objects/tag.py b/lib/git/objects/tag.py index 2e6ec878..702eae35 100644 --- a/lib/git/objects/tag.py +++ b/lib/git/objects/tag.py @@ -32,7 +32,7 @@ class TagObject(base.Object): it into a different format :param tagged_tz_offset: int_seconds_west_of_utc is the timezone that the authored_date is in, in a format similar to time.altzone""" - super(TagObject, self).__init__(repo, sha ) + super(TagObject, self).__init__(repo, binsha ) self._set_self_from_args_(locals()) def _set_cache_(self, attr): diff --git a/lib/git/objects/tree.py b/lib/git/objects/tree.py index b6902fbb..056d3da9 100644 --- a/lib/git/objects/tree.py +++ b/lib/git/objects/tree.py @@ -15,7 +15,10 @@ from fun import ( tree_to_stream ) -from gitdb.util import to_bin_sha +from gitdb.util import ( + to_bin_sha, + join + ) __all__ = ("TreeModifier", "Tree") @@ -61,7 +64,7 @@ class TreeModifier(object): :return: self""" if '/' in name: raise ValueError("Name must not contain '/' characters") - if (mode >> 12) not in self._map_id_to_type: + if (mode >> 12) not in Tree._map_id_to_type: raise ValueError("Invalid object type according to mode %o" % mode) sha = to_bin_sha(sha) @@ -150,7 +153,7 @@ class Tree(IndexObject, diff.Diffable, utils.Traversable, utils.Serializable): for binsha, mode, name in iterable: path = join(self.path, name) try: - yield self._map_id_to_type[type_id](self.repo, binsha, mode >> 12, path) + yield self._map_id_to_type[mode >> 12](self.repo, binsha, mode, path) except KeyError: raise TypeError("Unknown mode %o found in tree data for path '%s'" % (mode, path)) # END for each item |