diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-07 21:08:09 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-07 21:08:09 +0200 |
commit | 75c161cbc017a7d176dd0d7b937db26b3ce637a1 (patch) | |
tree | 4ee155db8b0bd0e5fb2ed56a167b0505e493ae7a | |
parent | 53ed0d43ab950d4deeefd238c7685dabef943800 (diff) | |
parent | 3410fdc42075bd788a78f4b2a68c5e2cc0930409 (diff) | |
download | gitpython-75c161cbc017a7d176dd0d7b937db26b3ce637a1.tar.gz |
Merge commit 'JonNordby/master' into integration
* commit 'JonNordby/master':
implemented equality operations on Commit objects
-rw-r--r-- | lib/git/commit.py | 6 | ||||
-rw-r--r-- | test/git/test_commit.py | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/git/commit.py b/lib/git/commit.py index a488c4a1..ba7a7102 100644 --- a/lib/git/commit.py +++ b/lib/git/commit.py @@ -67,6 +67,12 @@ class Commit(LazyMixin): if tree is not None: self.tree = Tree(repo, id=tree) + def __eq__(self, other): + return self.id == other.id + + def __ne__(self, other): + return self.id != other.id + def __bake__(self): temp = Commit.find_all(self.repo, self.id, max_count=1)[0] self.parents = temp.parents diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 3e37a7a4..e63edbcf 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -236,3 +236,10 @@ class TestCommit(object): def test_repr(self): commit = Commit(self.repo, id='abc') assert_equal('<git.Commit "abc">', repr(commit)) + + def test_equality(self): + commit1 = Commit(self.repo, id='abc') + commit2 = Commit(self.repo, id='abc') + commit3 = Commit(self.repo, id='zyx') + assert_equal(commit1, commit2) + assert_not_equal(commit2, commit3) |