def getGitVersion(tagPrefix):
 path = os.getcwd()
 if (not os.path.isdir(os.path.join(path, '.git'))):
  return None
 v = check_output(['git', 'describe', '--tags', '--dirty', ('--match=%s*' % tagPrefix)]).strip().decode('utf-8')
 assert v.startswith(tagPrefix)
 v = v[len(tagPrefix):]
 parts = v.split('-')
 modified = False
 if (parts[(-1)] == 'dirty'):
  modified = True
  parts = parts[:(-1)]
 local = None
 if ((len(parts) > 2) and re.match('\\d+', parts[(-2)]) and re.match('g[0-9a-f]{7}', parts[(-1)])):
  local = parts[(-1)]
  parts = parts[:(-2)]
 gitVersion = '-'.join(parts)
 if (local is not None):
  gitVersion += ('+' + local)
 if modified:
  gitVersion += 'm'
 return gitVersion

def getGitVersion ( tagPrefix ) : path = os . getcwd ( ) if ( not os . path . isdir ( os . path . join ( path , '.git' ) ) ) : return None v = check_output ( [ 'git' , 'describe' , '--tags' , '--dirty' , ( '--match=%s*' % tagPrefix ) ] ) . strip ( ) . decode ( 'utf-8' ) assert v . startswith ( tagPrefix ) v = v [ len ( tagPrefix ) : ] parts = v . split ( '-' ) modified = False if ( parts [ ( - 1 ) ] == 'dirty' ) : modified = True parts = parts [ : ( - 1 ) ] local = None if ( ( len ( parts ) > 2 ) and re . match ( '\\d+' , parts [ ( - 2 ) ] ) and re . match ( 'g[0-9a-f]{7}' , parts [ ( - 1 ) ] ) ) : local = parts [ ( - 1 ) ] parts = parts [ : ( - 2 ) ] gitVersion = '-' . join ( parts ) if ( local is not None ) : gitVersion += ( '+' + local ) if modified : gitVersion += 'm' return gitVersion
return a version string with information about this git checkout .