'Return map of named refs (branches or tags) to commit hashes.'

def get_refs(self, location):

    output = call_subprocess([self.cmd, 'show-ref'], show_stdout=False, cwd=location)
    rv = {}
    for line in output.strip().splitlines():
        (commit, ref) = line.split('    ', 1)
        ref = ref.strip()
        ref_name = None
        if ref.startswith('refs/remotes/'):
            ref_name = ref[len('refs/remotes/'):]
        elif ref.startswith('refs/heads/'):
            ref_name = ref[len('refs/heads/'):]
        elif ref.startswith('refs/tags/'):
            ref_name = ref[len('refs/tags/'):]
        if (ref_name is not None):
            rv[ref_name] = commit.strip()
    return rv
