summaryrefslogtreecommitdiff
path: root/lib/git_python/commit.py
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2008-05-20 15:56:38 +0200
committerFlorian Apolloner <florian@apolloner.eu>2008-05-20 15:56:38 +0200
commit35ddb45b41b3de2d4f783608ad8d8752f6557997 (patch)
treeaa5cc1acfcf65a4c7889846c227e85386090f719 /lib/git_python/commit.py
parent1dc09f0ece61ef2bd629e8bfe532aa24f4f8e0c2 (diff)
downloadgitpython-35ddb45b41b3de2d4f783608ad8d8752f6557997.tar.gz
removed unneeded spaces
Diffstat (limited to 'lib/git_python/commit.py')
-rw-r--r--lib/git_python/commit.py90
1 files changed, 45 insertions, 45 deletions
diff --git a/lib/git_python/commit.py b/lib/git_python/commit.py
index 0cd7715e..701f6c04 100644
--- a/lib/git_python/commit.py
+++ b/lib/git_python/commit.py
@@ -11,36 +11,36 @@ class Commit(LazyMixin):
def __init__(self, repo, **kwargs):
"""
Instantiate a new Commit
-
+
``id``
is the id of the commit
-
+
``parents``
is a list of commit ids (will be converted into Commit instances)
-
+
``tree``
is the correspdonding tree id (will be converted into a Tree object)
-
+
``author``
is the author string
-
+
``authored_date``
is the authored DateTime
-
+
``committer``
is the committer string
-
- ``committed_date``
+
+ ``committed_date``
is the committed DateTime
-
+
``message``
is the first line of the commit message
-
- Returns
+
+ Returns
GitPython.Commit
"""
LazyMixin.__init__(self)
-
+
self.repo = repo
self.id = None
self.tree = None
@@ -50,10 +50,10 @@ class Commit(LazyMixin):
self.committed_date = None
self.message = None
self.parents = None
-
+
for k, v in kwargs.items():
setattr(self, k, v)
-
+
if self.id:
if 'parents' in kwargs:
self.parents = map(lambda p: Commit(repo, **{'id': p}), kwargs['parents'])
@@ -73,18 +73,18 @@ class Commit(LazyMixin):
@property
def id_abbrev(self):
return self.id[0:7]
-
+
@classmethod
def count(cls, repo, ref):
"""
Count the number of commits reachable from this ref
-
+
``repo``
is the Repo
-
+
``ref``
is the ref from which to begin (SHA1 or name)
-
+
Returns
int
"""
@@ -96,21 +96,21 @@ class Commit(LazyMixin):
Find all commits matching the given criteria.
``repo``
is the Repo
-
+
``ref``
is the ref from which to begin (SHA1 or name)
-
+
``options``
is a Hash of optional arguments to git where
``max_count`` is the maximum number of commits to fetch
``skip`` is the number of commits to skip
-
+
Returns
GitPython.Commit[]
"""
options = {'pretty': 'raw'}
options.update(kwargs)
-
+
output = repo.git.rev_list(ref, **options)
return cls.list_from_string(repo, output)
@@ -118,10 +118,10 @@ class Commit(LazyMixin):
def list_from_string(cls, repo, text):
"""
Parse out commit information into a list of Commit objects
-
+
``repo``
is the Repo
-
+
``text``
is the text output from the git command (raw format)
@@ -129,46 +129,46 @@ class Commit(LazyMixin):
GitPython.Commit[]
"""
lines = [l for l in text.splitlines() if l.strip()]
-
+
commits = []
-
+
while lines:
id = lines.pop(0).split()[-1]
tree = lines.pop(0).split()[-1]
-
+
parents = []
while lines and re.search(r'^parent', lines[0]):
parents.append(lines.pop(0).split()[-1])
author, authored_date = cls.actor(lines.pop(0))
committer, committed_date = cls.actor(lines.pop(0))
-
+
messages = []
while lines and re.search(r'^ {4}', lines[0]):
messages.append(lines.pop(0).strip())
-
+
message = messages and messages[0] or ''
-
+
commits.append(Commit(repo, id=id, parents=parents, tree=tree, author=author, authored_date=authored_date,
committer=committer, committed_date=committed_date, message=message))
-
+
return commits
-
+
@classmethod
def diff(cls, repo, a, b = None, paths = []):
"""
Show diffs between two trees:
-
+
``repo``
is the Repo
-
+
``a``
is a named commit
-
+
``b``
- is an optional named commit. Passing a list assumes you
- wish to omit the second named commit and limit the diff to the
+ is an optional named commit. Passing a list assumes you
+ wish to omit the second named commit and limit the diff to the
given paths.
-
+
``paths``
is a list of paths to limit the diff.
@@ -178,10 +178,10 @@ class Commit(LazyMixin):
if isinstance(b, list):
paths = b
b = None
-
+
if paths:
paths.insert(0, "--")
-
+
if b:
paths.insert(0, b)
paths.insert(0, a)
@@ -200,8 +200,8 @@ class Commit(LazyMixin):
d = ''
return diff.Diff.list_from_string(self.repo, d)
else:
- return self.diff(self.repo, self.parents[0].id, self.id)
-
+ return self.diff(self.repo, self.parents[0].id, self.id)
+
@property
def stats(self):
if not self.parents:
@@ -214,14 +214,14 @@ class Commit(LazyMixin):
else:
text = self.repo.git.diff(self.parents[0].id, self.id, **{'numstat': True})
return stats.Stats.list_from_string(self.repo, text)
-
+
def __str__(self):
""" Convert commit to string which is SHA1 """
return self.id
-
+
def __repr__(self):
return '<GitPython.Commit "%s">' % self.id
-
+
@classmethod
def actor(cls, line):
"""