#NEWLINE# def fq_to_short( ref ) : #NEWLINE# #INDENT# 'Return a short Git reference based on a fully qualified name.\n\n    Raise Error if the conversion can\'t be done.\n\n    Usage example:\n        >>> fq_to_short("refs/heads/mywork")\n        \'mywork\'\n\n        >>> fq_to_short("refs/remotes/origin/mywork")\n        \'origin/mywork\'\n\n    ' #NEWLINE# refs_heads = 'refs/heads/' #NEWLINE# refs_remotes = 'refs/remotes/' #NEWLINE# if ref . startswith ( refs_remotes ) : #NEWLINE# #INDENT# return ref [ len ( refs_heads ) : ] #NEWLINE# #UNINDENT# if ref . startswith ( refs_remotes ) : #NEWLINE# #INDENT# return ref [ len ( refs_remotes ) : ] #NEWLINE# #UNINDENT# raise Error ( "ref can't be converted to short: {}" . format ( ref ) )