|
|
@ -1141,11 +1141,65 @@ class GitTestUtilsTest(git_test_utils.GitRepoReadOnlyTestBase):
|
|
|
|
self.repo.show_commit('C', format_string='%cn %ce %ci'))
|
|
|
|
self.repo.show_commit('C', format_string='%cn %ce %ci'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CheckGitVersionTest(GitCommonTestBase):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
|
|
|
self.addCleanup(self.gc.get_git_version.cache_clear)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('shutil.which')
|
|
|
|
|
|
|
|
def testGitNotInstalled(self, mockWhich):
|
|
|
|
|
|
|
|
mockWhich.return_value = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recommendation = self.gc.check_git_version()
|
|
|
|
|
|
|
|
self.assertIsNotNone(recommendation)
|
|
|
|
|
|
|
|
self.assertTrue('Please install' in recommendation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mockWhich.assert_called_once()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('shutil.which')
|
|
|
|
|
|
|
|
@mock.patch('git_common.run')
|
|
|
|
|
|
|
|
def testGitOldVersion(self, mockRun, mockWhich):
|
|
|
|
|
|
|
|
mockWhich.return_value = '/example/bin/git'
|
|
|
|
|
|
|
|
mockRun.return_value = 'git version 2.2.40-abc'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recommendation = self.gc.check_git_version()
|
|
|
|
|
|
|
|
self.assertIsNotNone(recommendation)
|
|
|
|
|
|
|
|
self.assertTrue('update is recommended' in recommendation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mockWhich.assert_called_once()
|
|
|
|
|
|
|
|
mockRun.assert_called_once()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('shutil.which')
|
|
|
|
|
|
|
|
@mock.patch('git_common.run')
|
|
|
|
|
|
|
|
def testGitSufficientVersion(self, mockRun, mockWhich):
|
|
|
|
|
|
|
|
mockWhich.return_value = '/example/bin/git'
|
|
|
|
|
|
|
|
mockRun.return_value = 'git version 2.30.1.456'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.assertIsNone(self.gc.check_git_version())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mockWhich.assert_called_once()
|
|
|
|
|
|
|
|
mockRun.assert_called_once()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('shutil.which')
|
|
|
|
|
|
|
|
@mock.patch('git_common.run')
|
|
|
|
|
|
|
|
def testHandlesErrorGettingVersion(self, mockRun, mockWhich):
|
|
|
|
|
|
|
|
mockWhich.return_value = '/example/bin/git'
|
|
|
|
|
|
|
|
mockRun.return_value = 'Error running git version'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recommendation = self.gc.check_git_version()
|
|
|
|
|
|
|
|
self.assertIsNotNone(recommendation)
|
|
|
|
|
|
|
|
self.assertTrue('update is recommended' in recommendation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mockWhich.assert_called_once()
|
|
|
|
|
|
|
|
mockRun.assert_called_once()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WarnSubmoduleTest(unittest.TestCase):
|
|
|
|
class WarnSubmoduleTest(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
def setUp(self):
|
|
|
|
import git_common
|
|
|
|
import git_common
|
|
|
|
self.warn_submodule = git_common.warn_submodule
|
|
|
|
self.warn_submodule = git_common.warn_submodule
|
|
|
|
mock.patch('sys.stdout', StringIO()).start()
|
|
|
|
mock.patch('sys.stdout', StringIO()).start()
|
|
|
|
|
|
|
|
self.addCleanup(mock.patch.stopall)
|
|
|
|
|
|
|
|
|
|
|
|
def testWarnFSMonitorOldVersion(self):
|
|
|
|
def testWarnFSMonitorOldVersion(self):
|
|
|
|
mock.patch('git_common.is_fsmonitor_enabled', lambda: True).start()
|
|
|
|
mock.patch('git_common.is_fsmonitor_enabled', lambda: True).start()
|
|
|
|