diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-09 11:57:48 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-09 11:57:48 +0200 |
commit | 92a97480edcc0f0de787a752bf90feed0445dd39 (patch) | |
tree | 518c00ba9840a2d6f32ffa7a876d7efa98016a03 /lib/git | |
parent | 2b7f5cb25e0e03e06ec506d31c001c172dd71ef6 (diff) | |
download | gitpython-92a97480edcc0f0de787a752bf90feed0445dd39.tar.gz |
Blob|Tree: renamed 'name' member to 'path', updated tests and changelog as it would make existing code incompatible in some places
Diffstat (limited to 'lib/git')
-rw-r--r-- | lib/git/blob.py | 16 | ||||
-rw-r--r-- | lib/git/diff.py | 4 | ||||
-rw-r--r-- | lib/git/tree.py | 14 |
3 files changed, 17 insertions, 17 deletions
diff --git a/lib/git/blob.py b/lib/git/blob.py index 82a41f73..dac0888f 100644 --- a/lib/git/blob.py +++ b/lib/git/blob.py @@ -15,7 +15,7 @@ class Blob(object): """A Blob encapsulates a git blob object""" DEFAULT_MIME_TYPE = "text/plain" - def __init__(self, repo, id, mode=None, name=None): + def __init__(self, repo, id, mode=None, path=None): """ Create an unbaked Blob containing just the specified attributes @@ -28,8 +28,8 @@ class Blob(object): ``mode`` is the file mode - ``name`` - is the file name + ``path`` + is the path to the file Returns git.Blob @@ -37,7 +37,7 @@ class Blob(object): self.repo = repo self.id = id self.mode = mode - self.name = name + self.path = path self._size = None self.data_stored = None @@ -83,17 +83,17 @@ class Blob(object): Defaults to 'text/plain' in case the actual file type is unknown. """ guesses = None - if self.name: - guesses = mimetypes.guess_type(self.name) + if self.path: + guesses = mimetypes.guess_type(self.path) return guesses and guesses[0] or self.DEFAULT_MIME_TYPE @property def basename(self): """ Returns - The basename of the Blobs file name + The basename of the Blobs file path """ - return os.path.basename(self.name) + return os.path.basename(self.path) @classmethod def blame(cls, repo, commit, file): diff --git a/lib/git/diff.py b/lib/git/diff.py index 44f55602..db12f1e4 100644 --- a/lib/git/diff.py +++ b/lib/git/diff.py @@ -38,11 +38,11 @@ class Diff(object): if not a_blob or re.search(r'^0{40}$', a_blob): self.a_blob = None else: - self.a_blob = blob.Blob(repo, id=a_blob, mode=a_mode, name=a_path) + self.a_blob = blob.Blob(repo, id=a_blob, mode=a_mode, path=a_path) if not b_blob or re.search(r'^0{40}$', b_blob): self.b_blob = None else: - self.b_blob = blob.Blob(repo, id=b_blob, mode=b_mode, name=b_path) + self.b_blob = blob.Blob(repo, id=b_blob, mode=b_mode, path=b_path) self.a_mode = a_mode self.b_mode = b_mode diff --git a/lib/git/tree.py b/lib/git/tree.py index cfb0881c..1b546f85 100644 --- a/lib/git/tree.py +++ b/lib/git/tree.py @@ -9,12 +9,12 @@ from lazy import LazyMixin import blob class Tree(LazyMixin): - def __init__(self, repo, id, mode=None, name=None): + def __init__(self, repo, id, mode=None, path=None): LazyMixin.__init__(self) self.repo = repo self.id = id self.mode = mode - self.name = name + self.path = path self._contents = None def __bake__(self): @@ -28,7 +28,7 @@ class Tree(LazyMixin): for line in self.repo.git.ls_tree(self.id).splitlines(): obj = self.content_from_string(self.repo, line) if obj is not None: - self._contents[obj.name] = obj + self._contents[obj.path] = obj @staticmethod def content_from_string(repo, text): @@ -45,14 +45,14 @@ class Tree(LazyMixin): ``git.Blob`` or ``git.Tree`` """ try: - mode, typ, id, name = text.expandtabs(1).split(" ", 3) + mode, typ, id, path = text.expandtabs(1).split(" ", 3) except: return None if typ == "tree": - return Tree(repo, id=id, mode=mode, name=name) + return Tree(repo, id=id, mode=mode, path=path) elif typ == "blob": - return blob.Blob(repo, id=id, mode=mode, name=name) + return blob.Blob(repo, id=id, mode=mode, path=path) elif typ == "commit": return None else: @@ -76,7 +76,7 @@ class Tree(LazyMixin): @property def basename(self): - os.path.basename(self.name) + os.path.basename(self.path) def __repr__(self): return '<git.Tree "%s">' % self.id |