diff options
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | lib/git/objects/commit.py | 9 | ||||
-rw-r--r-- | test/git/test_commit.py | 4 |
3 files changed, 14 insertions, 0 deletions
@@ -61,6 +61,7 @@ GitCommand Commit ------ * 'count' method is not an instance method to increase its ease of use +* 'name_rev' property returns a nice name for the commit's sha Config ------ diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py index 4080305f..0f8ed7f8 100644 --- a/lib/git/objects/commit.py +++ b/lib/git/objects/commit.py @@ -117,6 +117,15 @@ class Commit(base.Object, Iterable, diff.Diffable): """ return len(self.repo.git.rev_list(self.id, '--', paths, **kwargs).strip().splitlines()) + @property + def name_rev(self): + """ + Returns + String describing the commits hex sha based on the closest Reference. + Mostly useful for UI purposes + """ + return self.repo.git.name_rev(self) + @classmethod def iter_items(cls, repo, rev, paths='', **kwargs): """ diff --git a/test/git/test_commit.py b/test/git/test_commit.py index c4ed4b72..251387bd 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -94,3 +94,7 @@ class TestCommit(TestBase): assert first_parent == c.parents[0] # END for each + def test_base(self): + name_rev = self.rorepo.head.commit.name_rev + assert isinstance(name_rev, basestring) + |