def list_remote(local_root):
    """Get remote branch/tag latest SHAs.

    :raise GitError: When git ls-remote fails.

    :param str local_root: Local path to git root directory.

    :return: List of tuples containing strings. Each tuple is sha, name, kind.
    :rtype: list
    """
    command = ['git', 'ls-remote', '--heads', '--tags']
    try:
        output = run_command(local_root, command)
    except CalledProcessError as exc:
        raise GitError('Git failed to list remote refs.', exc.output)

    # Dereference annotated tags if any. No need to fetch annotations.
    if '^{}' in output:
        parsed = list()
        for group in (m.groupdict() for m in RE_REMOTE.finditer(output)):
            dereferenced, name, kind = group['name'].endswith('^{}'), group['name'][:-3], group['kind']
            if dereferenced and parsed and kind == parsed[-1]['kind'] == 'tags' and name == parsed[-1]['name']:
                parsed[-1]['sha'] = group['sha']
            else:
                parsed.append(group)
    else:
        parsed = [m.groupdict() for m in RE_REMOTE.finditer(output)]

    return [[i['sha'], i['name'], i['kind']] for i in parsed]
def list_remote ( local_root ) : command = [ 'git' , 'ls-remote' , '--heads' , '--tags' ] try : output = run_command ( local_root , command ) except CalledProcessError as exc : raise GitError ( 'Git failed to list remote refs.' , exc . output ) if '^{}' in output : parsed = list ( ) for group in ( m . groupdict ( ) for m in RE_REMOTE . finditer ( output ) ) : dereferenced , name , kind = group [ 'name' ] . endswith ( '^{}' ) , group [ 'name' ] [ : - 3 ] , group [ 'kind' ] if dereferenced and parsed and kind == parsed [ - 1 ] [ 'kind' ] == 'tags' and name == parsed [ - 1 ] [ 'name' ] : parsed [ - 1 ] [ 'sha' ] = group [ 'sha' ] else : parsed . append ( group ) else : parsed = [ m . groupdict ( ) for m in RE_REMOTE . finditer ( output ) ] return [ [ i [ 'sha' ] , i [ 'name' ] , i [ 'kind' ] ] for i in parsed ]
Get remote branch/tag latest SHAs.

    :raise GitError: When git ls-remote fails.

    :param str local_root: Local path to git root directory.

    :return: List of tuples containing strings. Each tuple is sha, name, kind.
    :rtype: list