def fq_to_short(ref):
    refs_heads = 'refs/heads/'
    refs_remotes = 'refs/remotes/'

    if ref.startswith(refs_heads):
        return ref[len(refs_heads):]

    if ref.startswith(refs_remotes):
        return ref[len(refs_remotes):]

    raise Error("ref can't be converted to short: {}".format(ref))
Return a short Git reference based on a fully qualified name.
dataset/ETHPy150Open bloomberg/phabricator-tools/py/phl/phlgitu_ref.py/fq_to_short