Updates for issue #365:
Adding commit SHA output to version option. The SHA will only be reported if the git repo has been cloned. When installed via PIP, the SHA will not be reported.
This commit is contained in:
parent
5d1b796207
commit
fb2a22eb4c
|
|
@ -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 = []
|
||||
|
|
|
|||
|
|
@ -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 ''
|
||||
|
|
|
|||
Loading…
Reference in New Issue