def METHOD_NAME(repopath):
    """
    Return Git revision for the repository located at repopath
    Result is a tuple (latest commit hash, branch), falling back to
    SPY_COMMIT and SPY_BRANCH environment variables, if present, else None.
    """
    try:
        git = programs.find_git()
        assert git is not None and osp.isdir(osp.join(repopath, '.git'))
        commit = programs.run_program(git, ['rev-parse', '--short', 'HEAD'],
                                      cwd=repopath).communicate()
        commit = commit[0].strip()
        commit = commit.decode(sys.getdefaultencoding())
        # Branch
        branches = programs.run_program(git, ['branch'],
                                        cwd=repopath).communicate()
        branches = branches[0]
        branches = branches.decode(sys.getdefaultencoding())
        branches = branches.split('\n')
        active_branch = [b for b in branches if b.startswith('*')]
        if len(active_branch) != 1:
            branch = None
        else:
            branch = active_branch[0].split(None, 1)[1]
        return commit, branch
    except (subprocess.CalledProcessError, AssertionError, AttributeError,
            OSError):
        return os.environ.get('SPY_COMMIT'), os.environ.get('SPY_BRANCH')