in tools/sonar/gen_sonar_project_properties.py [0:0]
def get_plugin_version(plugin_dir):
version = '1.0'
version_file_path = path.join(plugin_dir, 'VERSION')
if path.exists(version_file_path):
try:
with open(version_file_path, "r") as version_file:
data = re.sub(r"\s+", '', version_file.read())
except Exception as err:
print('error reading plugin version: %s' % err)
else:
match = re.search(r"PLUGIN_VERSION='(.*?)'", data)
if match:
version = match.group(1)
elif path.exists(path.join(plugin_dir, '.git')):
version = check_output(['git', 'describe', '--always', 'HEAD'],
cwd=plugin_dir).decode('utf-8')
return version