def _get_version_from_git(pre_version):
 if os.path.isdir('.git'):
  if pre_version:
   try:
    return _run_shell_command('git describe --exact-match', throw_on_error=True).replace('-', '.')
   except Exception:
    sha = _run_shell_command('git log -n1 --pretty=format:%h')
    return ('%s.a%s.g%s' % (pre_version, _get_revno(), sha))
  else:
   return _run_shell_command('git describe --always').replace('-', '.')
 return None

def _get_version_from_git ( pre_version ) : if os . path . isdir ( '.git' ) : if pre_version : try : return _run_shell_command ( 'git describe --exact-match' , throw_on_error = True ) . replace ( '-' , '.' ) except Exception : sha = _run_shell_command ( 'git log -n1 --pretty=format:%h' ) return ( '%s.a%s.g%s' % ( pre_version , _get_revno ( ) , sha ) ) else : return _run_shell_command ( 'git describe --always' ) . replace ( '-' , '.' ) return None
return a version which is equal to the tag thats on the current revision if there is one .