#NEWLINE# def git_parse_vcs_describe( git_describe , tag_prefix , verbose = False ) : #NEWLINE# #INDENT# dirty = git_describe . endswith ( '-dirty' ) #NEWLINE# if dirty : #NEWLINE# #INDENT# git_describe = git_describe [ : git_describe . rindex ( '-dirty' ) ] #NEWLINE# #UNINDENT# dirty_suffix = ( '.dirty' if dirty else '' ) #NEWLINE# if ( '-' not in git_describe ) : #NEWLINE# #INDENT# return ( ( ( '0+untagged.g' + git_describe ) + dirty_suffix ) , dirty ) #NEWLINE# #UNINDENT# mo = re . search ( '^(.+)-(\\d+)-g([0-9a-f]+)$' , git_describe ) #NEWLINE# if ( not mo ) : #NEWLINE# #INDENT# return ( ( '0+unparseable' + dirty_suffix ) , dirty ) #NEWLINE# #UNINDENT# full_tag = mo . group ( 1 ) #NEWLINE# if ( not full_tag . startswith ( tag_prefix ) ) : #NEWLINE# #INDENT# if verbose : #NEWLINE# #INDENT# fmt = "tag '%s' doesn't start with prefix '%s'" #NEWLINE# print ( ( fmt % ( full_tag , tag_prefix ) ) ) #NEWLINE# #UNINDENT# return ( None , dirty ) #NEWLINE# #UNINDENT# tag = full_tag [ len ( tag_prefix ) : ] #NEWLINE# distance = int ( mo . group ( 2 ) ) #NEWLINE# commit = mo . group ( 3 ) #NEWLINE# version = tag #NEWLINE# if ( distance or dirty ) : #NEWLINE# #INDENT# version += ( ( '+%d.g%s' % ( distance , commit ) ) + dirty_suffix ) #NEWLINE# #UNINDENT# return ( version , dirty )