diff --git a/kallithea/lib/vcs/backends/git/repository.py b/kallithea/lib/vcs/backends/git/repository.py --- a/kallithea/lib/vcs/backends/git/repository.py +++ b/kallithea/lib/vcs/backends/git/repository.py @@ -634,8 +634,7 @@ class GitRepository(BaseRepository): if path: cmd += ['--', path] - stdout, stderr = self.run_git_command(cmd) - # TODO: don't ignore stderr + stdout, stderr = self._run_git_command(cmd, cwd=self.path) # If we used 'show' command, strip first few lines (until actual diff # starts) if rev1 == self.EMPTY_CHANGESET: diff --git a/kallithea/tests/vcs/test_git.py b/kallithea/tests/vcs/test_git.py --- a/kallithea/tests/vcs/test_git.py +++ b/kallithea/tests/vcs/test_git.py @@ -665,65 +665,65 @@ class TestGitSpecificWithRepo(_BackendTe assert self.repo.workdir.get_branch() == 'master' def test_get_diff_runs_git_command_with_hashes(self): - self.repo.run_git_command = mock.Mock(return_value=['', '']) + self.repo._run_git_command = mock.Mock(return_value=(b'', b'')) self.repo.get_diff(0, 1) - self.repo.run_git_command.assert_called_once_with( + self.repo._run_git_command.assert_called_once_with( ['diff', '-U3', '--full-index', '--binary', '-p', '-M', '--abbrev=40', - self.repo._get_revision(0), self.repo._get_revision(1)]) + self.repo._get_revision(0), self.repo._get_revision(1)], cwd=self.repo.path) def test_get_diff_runs_git_command_with_str_hashes(self): - self.repo.run_git_command = mock.Mock(return_value=['', '']) + self.repo._run_git_command = mock.Mock(return_value=(b'', b'')) self.repo.get_diff(self.repo.EMPTY_CHANGESET, 1) - self.repo.run_git_command.assert_called_once_with( + self.repo._run_git_command.assert_called_once_with( ['show', '-U3', '--full-index', '--binary', '-p', '-M', '--abbrev=40', - self.repo._get_revision(1)]) + self.repo._get_revision(1)], cwd=self.repo.path) def test_get_diff_runs_git_command_with_path_if_its_given(self): - self.repo.run_git_command = mock.Mock(return_value=['', '']) + self.repo._run_git_command = mock.Mock(return_value=(b'', b'')) self.repo.get_diff(0, 1, 'foo') - self.repo.run_git_command.assert_called_once_with( + self.repo._run_git_command.assert_called_once_with( ['diff', '-U3', '--full-index', '--binary', '-p', '-M', '--abbrev=40', - self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo']) + self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo'], cwd=self.repo.path) def test_get_diff_does_not_sanitize_valid_context(self): almost_overflowed_long_int = 2**31-1 - self.repo.run_git_command = mock.Mock(return_value=['', '']) + self.repo._run_git_command = mock.Mock(return_value=(b'', b'')) self.repo.get_diff(0, 1, 'foo', context=almost_overflowed_long_int) - self.repo.run_git_command.assert_called_once_with( + self.repo._run_git_command.assert_called_once_with( ['diff', '-U' + str(almost_overflowed_long_int), '--full-index', '--binary', '-p', '-M', '--abbrev=40', - self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo']) + self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo'], cwd=self.repo.path) def test_get_diff_sanitizes_overflowing_context(self): overflowed_long_int = 2**31 sanitized_overflowed_long_int = overflowed_long_int-1 - self.repo.run_git_command = mock.Mock(return_value=['', '']) + self.repo._run_git_command = mock.Mock(return_value=(b'', b'')) self.repo.get_diff(0, 1, 'foo', context=overflowed_long_int) - self.repo.run_git_command.assert_called_once_with( + self.repo._run_git_command.assert_called_once_with( ['diff', '-U' + str(sanitized_overflowed_long_int), '--full-index', '--binary', '-p', '-M', '--abbrev=40', - self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo']) + self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo'], cwd=self.repo.path) def test_get_diff_does_not_sanitize_zero_context(self): zero_context = 0 - self.repo.run_git_command = mock.Mock(return_value=['', '']) + self.repo._run_git_command = mock.Mock(return_value=(b'', b'')) self.repo.get_diff(0, 1, 'foo', context=zero_context) - self.repo.run_git_command.assert_called_once_with( + self.repo._run_git_command.assert_called_once_with( ['diff', '-U' + str(zero_context), '--full-index', '--binary', '-p', '-M', '--abbrev=40', - self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo']) + self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo'], cwd=self.repo.path) def test_get_diff_sanitizes_negative_context(self): negative_context = -10 - self.repo.run_git_command = mock.Mock(return_value=['', '']) + self.repo._run_git_command = mock.Mock(return_value=(b'', b'')) self.repo.get_diff(0, 1, 'foo', context=negative_context) - self.repo.run_git_command.assert_called_once_with( + self.repo._run_git_command.assert_called_once_with( ['diff', '-U0', '--full-index', '--binary', '-p', '-M', '--abbrev=40', - self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo']) + self.repo._get_revision(0), self.repo._get_revision(1), '--', 'foo'], cwd=self.repo.path) class TestGitRegression(_BackendTestMixin):