Merge "Fix TypeError when reporting old git version"

This commit is contained in:
Zuul
2025-05-15 16:36:28 +00:00
committed by Gerrit Code Review
2 changed files with 15 additions and 2 deletions

View File

@@ -255,9 +255,9 @@ def get_git_version():
printwrap("Could not determine git version!")
sys.exit(1)
if LOCAL_GIT_VERSION < MINIMUM_GIT_VERSION:
printwrap("Local git version %s < required git version %s" %
printwrap("Local git version %s < required git version %s" % (
'.'.join(map(str, LOCAL_GIT_VERSION)),
'.'.join(map(str, MINIMUM_GIT_VERSION)))
'.'.join(map(str, MINIMUM_GIT_VERSION))))
sys.exit(1)

View File

@@ -469,3 +469,16 @@ class RepoUrlParsingTest(testtools.TestCase):
r'ssh://someone%40example.org@review.opendev.org:29418/x/y'),
('review.opendev.org', r'someone%40example.org', '29418',
'x/y'))
@mock.patch('git_review.cmd.run_command')
class GitVersionTest(testtools.TestCase):
def test_version_too_low(self, mock_run_command):
# From an old CentOS 7 box
mock_run_command.return_value = 'git version 1.8.3.1'
self.assertRaises(SystemExit, cmd.get_git_version)
def test_version_good(self, mock_run_command):
mock_run_command.return_value = 'git version 2.43.0'
self.assertIsNone(cmd.get_git_version())
self.assertEqual(cmd.LOCAL_GIT_VERSION, (2, 43, 0))