summaryrefslogtreecommitdiff
path: root/lib/git/blob.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-20 17:32:52 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-20 17:32:52 +0200
commit13ac6b6aa35f01eb50590998e1e5e9a41d186046 (patch)
tree34119f1d188fbbba640e10105c60e62717484ec7 /lib/git/blob.py
parent4c39f9da792792d4e73fc3a5effde66576ae128c (diff)
parentf4874ca00b5f6bcba3a62d5776a4b2da899c8846 (diff)
downloadgitpython-13ac6b6aa35f01eb50590998e1e5e9a41d186046.tar.gz
Merge commit 'origin/improvements_for_mainline' into integration
* commit 'origin/improvements_for_mainline': Moved compatibility information of possible future release into right spot ( to the top of the release list ) repo_tests: fixed duplicate test-method name which would redefine the previous one which never ran Fixed Diff class which used Commits instead of Blobs - as Blobs contain the path ( in the 'name' member variable ), the a|b_path members of Diff have been removed. Tests were adjusted and run git.git.Git.__init__ takes None as default argument as the execute method handles this correctly Fixed git.blob.Blob.blame function which would return the text-per-commit as individual characters improved repo documentation Improved head and tag object documentation slightly Added docs for the error module Added missing information to docstrings of commit and stats module improved git.cmd documentation Improved documentation on Actor and Blob
Diffstat (limited to 'lib/git/blob.py')
-rw-r--r--lib/git/blob.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/git/blob.py b/lib/git/blob.py
index 82f92ce3..82a41f73 100644
--- a/lib/git/blob.py
+++ b/lib/git/blob.py
@@ -12,6 +12,7 @@ from actor import Actor
from commit import Commit
class Blob(object):
+ """A Blob encapsulates a git blob object"""
DEFAULT_MIME_TYPE = "text/plain"
def __init__(self, repo, id, mode=None, name=None):
@@ -48,6 +49,9 @@ class Blob(object):
Returns
int
+
+ NOTE
+ The size will be cached after the first access
"""
if self._size is None:
self._size = int(self.repo.git.cat_file(self.id, s=True).rstrip())
@@ -60,6 +64,9 @@ class Blob(object):
Returns
str
+
+ NOTE
+ The data will be cached after the first access.
"""
self.data_stored = self.data_stored or self.repo.git.cat_file(self.id, p=True, with_raw_output=True)
return self.data_stored
@@ -71,6 +78,9 @@ class Blob(object):
Returns
str
+
+ NOTE
+ Defaults to 'text/plain' in case the actual file type is unknown.
"""
guesses = None
if self.name:
@@ -79,6 +89,10 @@ class Blob(object):
@property
def basename(self):
+ """
+ Returns
+ The basename of the Blobs file name
+ """
return os.path.basename(self.name)
@classmethod
@@ -88,6 +102,9 @@ class Blob(object):
Returns
list: [git.Commit, list: [<line>]]
+ A list of tuples associating a Commit object with a list of lines that
+ changed within the given commit. The Commit objects will be given in order
+ of appearance.
"""
data = repo.git.blame(commit, '--', file, p=True)
commits = {}
@@ -135,7 +152,7 @@ class Blob(object):
m = re.search(r'^\t(.*)$', line)
text, = m.groups()
blames[-1][0] = c
- blames[-1][1] += text
+ blames[-1][1].append( text )
info = None
return blames