diff --git a/vsg/tests/vsg/test_vsg.py b/vsg/tests/vsg/test_vsg.py index a55e6b4c..ed399dab 100644 --- a/vsg/tests/vsg/test_vsg.py +++ b/vsg/tests/vsg/test_vsg.py @@ -277,11 +277,10 @@ class testVsg(unittest.TestCase): def test_version_command_line_argument(self): lExpected = [] lExpected.append('VHDL Style Guide (VSG) version ' + version.version) - lExpected.append('') lActual = subprocess.check_output(['bin/vsg','--version']) lActual = str(lActual.decode('utf-8')).split('\n') - self.assertEqual(lActual, lExpected) + self.assertEqual(lExpected[0], lActual[0]) def test_missing_configuration_file(self): lExpected = [] diff --git a/vsg/version.py b/vsg/version.py index 75ae1e95..46d459d8 100644 --- a/vsg/version.py +++ b/vsg/version.py @@ -1,8 +1,22 @@ version = '2.0.0' +import subprocess def print_version(oCommandLineArguments): if (oCommandLineArguments.version): print('VHDL Style Guide (VSG) version ' + str(version)) + + print(retrieve_git_sha()) + exit(0) + + +def retrieve_git_sha(): + + try: + sShaNum = subprocess.check_output(['git', 'log', '--pretty=%h', '-n', '1'], stderr=subprocess.STDOUT) + sShaNum = sShaNum.decode('utf-8').strip() + return f'Git commit SHA: {sShaNum}' + except subprocess.CalledProcessError: + return ''