summaryrefslogtreecommitdiff
path: root/test/git/test_commit.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-18 14:25:14 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-18 14:25:14 +0200
commit225999e9442c746333a8baa17a6dbf7341c135ca (patch)
tree82e4bdf8a59fae869bae41aa6b9b048fee2d3e09 /test/git/test_commit.py
parent919164df96d9f956c8be712f33a9a037b097745b (diff)
parent9acc7806d6bdb306a929c460437d3d03e5e48dcd (diff)
downloadgitpython-225999e9442c746333a8baa17a6dbf7341c135ca.tar.gz
Merge branch 'diffing' into improvements
* diffing: DiffIndex implemented including test diff: implemented raw diff parsing which appears to be able to handle possible input types, DiffIndex still requires implementation though resolved cyclic inclusion issue by moving the Diffable interface into the diff module, which probably is the right thing to do anyway repo: fixed untracked files function which used git-commit before, it can open vim to get a message though which makes the program appear to freeze - using git-status now implemented diff tests, but will have to move the diff module as it needs to create objects, whose import would create a dependency cycle Removed a few diff-related test cases that fail now as the respective method is missing - these tests have to be redone in test-diff module accordingly added Diffable interface to objects.base, its used by Commit and Tree objects. Fixed object bug that would cause object ids not to be resolved to sha's as this was assumed - now there is a test for it as well
Diffstat (limited to 'test/git/test_commit.py')
-rw-r--r--test/git/test_commit.py150
1 files changed, 0 insertions, 150 deletions
diff --git a/test/git/test_commit.py b/test/git/test_commit.py
index 4e698ed0..c8bca564 100644
--- a/test/git/test_commit.py
+++ b/test/git/test_commit.py
@@ -20,156 +20,6 @@ class TestCommit(object):
assert_equal("byronimo@gmail.com", commit.author.email)
- @patch_object(Git, '_call_process')
- def test_diff(self, git):
- git.return_value = fixture('diff_p')
-
- diffs = Commit.diff(self.repo, 'master')
-
- assert_equal(15, len(diffs))
-
- diff = diffs[0]
- assert_equal('.gitignore', diff.a_blob.path)
- assert_equal('.gitignore', diff.b_blob.path)
- assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diff.a_blob.id)
- assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diff.b_blob.id)
-
- assert_mode_644(diff.b_blob.mode)
-
- assert_equal(False, diff.new_file)
- assert_equal(False, diff.deleted_file)
- assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diff.diff)
-
- diff = diffs[5]
- assert_equal('lib/grit/actor.rb', diff.b_blob.path)
- assert_equal(None, diff.a_blob)
- assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diff.b_blob.id)
- assert_equal( None, diff.a_mode )
- assert_equal(True, diff.new_file)
-
- assert_true(git.called)
- assert_equal(git.call_args, (('diff', '-M', 'master'), {'full_index': True}))
-
- @patch_object(Git, '_call_process')
- def test_diff_with_rename(self, git):
- git.return_value = fixture('diff_rename')
-
- diffs = Commit.diff(self.repo, 'rename')
-
- assert_equal(1, len(diffs))
-
- diff = diffs[0]
- assert_true(diff.renamed)
- assert_equal(diff.rename_from, 'AUTHORS')
- assert_equal(diff.rename_to, 'CONTRIBUTORS')
-
- assert_true(git.called)
- assert_equal(git.call_args, (('diff', '-M', 'rename'), {'full_index': True}))
-
- @patch_object(Git, '_call_process')
- def test_diff_with_two_commits(self, git):
- git.return_value = fixture('diff_2')
-
- diffs = Commit.diff(self.repo, '59ddc32', '13d27d5')
-
- assert_equal(3, len(diffs))
-
- assert_true(git.called)
- assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5'), {'full_index': True}))
-
- @patch_object(Git, '_call_process')
- def test_diff_with_files(self, git):
- git.return_value = fixture('diff_f')
-
- diffs = Commit.diff(self.repo, '59ddc32', ['lib'])
-
- assert_equal(1, len(diffs))
- assert_equal('lib/grit/diff.rb', diffs[0].a_blob.path)
-
- assert_true(git.called)
- assert_equal(git.call_args, (('diff', '-M', '59ddc32', '--', 'lib'), {'full_index': True}))
-
- @patch_object(Git, '_call_process')
- def test_diff_with_two_commits_and_files(self, git):
- git.return_value = fixture('diff_2f')
-
- diffs = Commit.diff(self.repo, '59ddc32', '13d27d5', ['lib'])
-
- assert_equal(1, len(diffs))
- assert_equal('lib/grit/commit.rb', diffs[0].a_blob.path)
-
- assert_true(git.called)
- assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True}))
-
- @patch_object(Git, '_call_process')
- def test_diffs(self, git):
- git.return_value = fixture('diff_p')
-
- commit = Commit(self.repo, id='91169e1f5fa4de2eaea3f176461f5dc784796769', parents=['038af8c329ef7c1bae4568b98bd5c58510465493'])
- diffs = commit.diffs
-
- assert_equal(15, len(diffs))
-
- diff = diffs[0]
- assert_equal('.gitignore', diff.a_blob.path)
- assert_equal('.gitignore', diff.b_blob.path)
- assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diff.a_blob.id)
- assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diff.b_blob.id)
- assert_mode_644(diff.b_blob.mode)
- assert_equal(False, diff.new_file)
- assert_equal(False, diff.deleted_file)
- assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diff.diff)
-
- diff = diffs[5]
- assert_equal('lib/grit/actor.rb', diff.b_blob.path)
- assert_equal(None, diff.a_blob)
- assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diff.b_blob.id)
- assert_equal(True, diff.new_file)
-
- assert_true(git.called)
- assert_equal(git.call_args, (('diff', '-M',
- '038af8c329ef7c1bae4568b98bd5c58510465493',
- '91169e1f5fa4de2eaea3f176461f5dc784796769',
- ), {'full_index': True}))
-
- def test_diffs_on_initial_import(self):
- commit = Commit(self.repo, '33ebe7acec14b25c5f84f35a664803fcab2f7781')
-
- for diff in commit.diffs:
- assert isinstance(diff, Diff)
- assert isinstance(diff.a_blob, Blob) or isinstance(diff.b_blob, Blob)
-
- if diff.a_mode is not None:
- assert isinstance(diff.a_mode, int)
- if diff.b_mode is not None:
- isinstance(diff.b_mode, int)
-
- assert diff.diff is not None # can be empty
-
- if diff.renamed:
- assert diff.rename_from and diff.rename_to and diff.rename_from != diff.rename_to
- if diff.a_blob is None:
- assert diff.new_file and isinstance(diff.new_file, bool)
- if diff.b_blob is None:
- assert diff.deleted_file and isinstance(diff.deleted_file, bool)
- # END for each diff in initial import commit
-
- def test_diffs_on_initial_import_without_parents(self):
- commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781')
- diffs = commit.diffs
- assert diffs
-
- def test_diffs_with_mode_only_change(self):
- commit = Commit(self.repo, id='ccde80b7a3037a004a7807a6b79916ce2a1e9729')
- diffs = commit.diffs
-
- # in case of mode-only changes, there is no blob
- assert_equal(1, len(diffs))
- assert_equal(None, diffs[0].a_blob)
- assert_equal(None, diffs[0].b_blob)
- assert_mode_644(diffs[0].a_mode)
- assert_mode_755(diffs[0].b_mode)
-
def test_stats(self):
commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781')
stats = commit.stats