summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sowden <paul@idontsmoke.co.uk>2008-11-23 20:49:07 -0800
committerMichael Trier <mtrier@gmail.com>2008-12-15 14:18:30 -0500
commit6c486b2e699082763075a169c56a4b01f99fc4b9 (patch)
treeee694c04f87787897a394e76c3bd6461c8581a5a
parent5da34fddda2ea6de19ecf04efd75e323c4bb41e4 (diff)
downloadgitpython-6c486b2e699082763075a169c56a4b01f99fc4b9.tar.gz
Make message the full message and add a summary property
Adds a summary property to the Commit object which returns just the first line of the commit message and makes the message property contain the entire commit message (previously the message property only contained the first line of the commit message). This breaks backwards compatibility a little in that the message property now contains a different value but previously there was no way to access the entire commit message from the Commit object and this is in keeping with git vocabulary, where message generally refers to the entire commit message. (cherry picked from commit 9d2962d8306c894d4cca55bab551677b92d96352)
-rw-r--r--lib/git/commit.py8
-rw-r--r--test/git/test_repo.py2
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/git/commit.py b/lib/git/commit.py
index c9e2ab59..4aee1280 100644
--- a/lib/git/commit.py
+++ b/lib/git/commit.py
@@ -41,7 +41,7 @@ class Commit(LazyMixin):
is the committed DateTime
``message``
- is the first line of the commit message
+ is the commit message
``parents``
is the list of the parents of the commit
@@ -81,6 +81,10 @@ class Commit(LazyMixin):
def id_abbrev(self):
return self.id[0:7]
+ @property
+ def summary(self):
+ return self.message.split('\n', 1)[0]
+
@classmethod
def count(cls, repo, ref, path=''):
"""
@@ -159,7 +163,7 @@ class Commit(LazyMixin):
while lines and lines[0].startswith(' '):
messages.append(lines.pop(0).strip())
- message = messages and messages[0] or ''
+ message = '\n'.join(messages)
commits.append(Commit(repo, id=id, parents=parents, tree=tree, author=author, authored_date=authored_date,
committer=committer, committed_date=committed_date, message=message))
diff --git a/test/git/test_repo.py b/test/git/test_repo.py
index e5264a0d..8b767744 100644
--- a/test/git/test_repo.py
+++ b/test/git/test_repo.py
@@ -67,7 +67,7 @@ class TestRepo(object):
c = commits[2]
assert_equal(["6e64c55896aabb9a7d8e9f8f296f426d21a78c2c", "7f874954efb9ba35210445be456c74e037ba6af2"], map(lambda p: p.id, c.parents))
- assert_equal("Merge branch 'site'", c.message)
+ assert_equal("Merge branch 'site'", c.summary)
assert_true(git.called)
assert_equal(git.call_args, (('rev_list', 'master', '--', ''), {'skip': 0, 'pretty': 'raw', 'max_count': 10}))