#NEWLINE# def get_last_tag_by_date( directory = None ) : #NEWLINE# #INDENT# "\n    Returns the most recent, by date, tag in the given local git repository.\n\n    :param directory: the directory in which to run the query\n    :returns: the most recent tag by date, else '' if there are no tags\n\n    :raises: subprocess.CalledProcessError if git command fails\n    " #NEWLINE# cmd = "git for-each-ref --sort='*authordate' --format='%(refname:short)' refs/tags/upstream" #NEWLINE# output = check_output ( cmd , shell = True , cwd = directory , stderr = PIPE ) #NEWLINE# output = output . splitlines ( ) #NEWLINE# if ( len ( output ) == 0 ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# return output [ ( - 1 ) ]