Fetch from origin.

    :raise CalledProcessError: Unhandled git command failure.

    :param str local_root: Local path to git root directory.
    :param iter remotes: Output of list_remote().
3032
def fetch_commits(local_root, remotes):
    
    # Fetch all known branches.
    command = ['git', 'fetch', 'origin']
    run_command(local_root, command)

    # Fetch new branches/tags.
    for sha, name, kind in remotes:
        try:
            run_command(local_root, ['git', 'reflog', sha])
        except CalledProcessError:
            run_command(local_root, command + ['refs/{0}/{1}'.format(kind, name)])
            run_command(local_root, ['git', 'reflog', sha])
331655
def __get_remote_index(self):
        
        # cleanup
        subprocess.getoutput("rm tmpaws.txt")
        # get the remote info
        cmd = "aws s3 ls --recursive s3://commoncrawl/crawl-data/CC-NEWS/ --no-sign-request > tmpaws.txt && " \
              "awk '{ print $4 }' tmpaws.txt && " \
              "rm tmpaws.txt"
        self.__logger.info('executing: %s', cmd)
        stdout_data = subprocess.getoutput(cmd)
        print(stdout_data)

        lines = stdout_data.splitlines()
        return lines
1028719
def local_async(self, *args, **kwargs):
        '''
        
        '''
        local = salt.client.get_local_client(mopts=self.opts)
        ret = local.run_job(*args, **kwargs)
        return ret
738344
def local(tool, slug, config_loader, offline=False):
    
    # Parse slug
    slug = Slug(slug, offline=offline)

    local_path = Path(LOCAL_PATH).expanduser() / slug.org / slug.repo

    git = Git(f"-C {shlex.quote(str(local_path))}")
    if not local_path.exists():
        _run(Git()(f"init {shlex.quote(str(local_path))}"))
        _run(git(f"remote add origin https://github.com/{slug.org}/{slug.repo}"))

    if not offline:
        # Get latest version of checks
        _run(git(f"fetch origin {slug.branch}"))

    # Ensure that local copy of the repo is identical to remote copy
    _run(git(f"checkout -f -B {slug.branch} origin/{slug.branch}"))
    _run(git(f"reset --hard HEAD"))

    problem_path = (local_path / slug.problem).absolute()

    if not problem_path.exists():
        raise InvalidSlugError(_("{} does not exist at {}/{}").format(slug.problem, slug.org, slug.repo))

    # Get config
    try:
        with open(problem_path / ".cs50.yaml") as f:
            try:
                config = config_loader.load(f.read())
            except InvalidConfigError:
                raise InvalidSlugError(
                    _("Invalid slug for {}. Did you mean something else?").format(tool))
    except FileNotFoundError:
        raise InvalidSlugError(_("Invalid slug. Did you mean something else?"))

    return problem_path
1253342
def branches(self):
        

        # first pull the local branches
        local_branches = self.repo.branches
        data = [[x.name, True] for x in list(local_branches)]

        # then the remotes
        remote_branches = self.repo.git.branch(all=True).split('\n')
        if sys.version_info.major == 2:
            remote_branches = set([x.split('/')[-1] for x in remote_branches if 'remotes' in x])
        else:
            remote_branches = {x.split('/')[-1] for x in remote_branches if 'remotes' in x}

        data += [[x, False] for x in remote_branches]

        df = DataFrame(data, columns=['branch', 'local'])
        df['repository'] = self._repo_name()

        return df
90511
def iter_items(cls, repo, common_path=None, remote=None):
        """"""
        common_path = common_path or cls._common_path_default
        if remote is not None:
            common_path = join_path(common_path, str(remote))
        # END handle remote constraint
        return super(RemoteReference, cls).iter_items(repo, common_path)
1151158
async function synchRepo(remote, pathname) {
  const cmd = `git subtree push --prefix=${pathname} ${remote} master`;

  try {
    await exec(cmd);
    logger.log(`Synched master of ${pathname}`);
  } catch (error) {
    throw error;
  }
}
815407
def read_remote_origin(repo_dir):
    """"""
    conf = ConfigParser()
    conf.read(os.path.join(repo_dir, '.git/config'))
    return conf.get('remote "origin"', 'url')
577627
def get_remote_url(path, remote="origin"):
    
    path = get_path(path)
    cmd = ["config", "--get", "remote.%s.url" % remote]
    return __run_git(cmd, path)[0]
1055811
def get_url(self):
        
        cmd = {
            'hg': 'hg paths default',
            'git': 'git config --local --get remote.origin.url',
        }[self.vcs_type]
        with chdir(self.folder):
            r = self.run(cmd)
        return r.output.replace('\n', '')
417304
def download(remote_location, remotes=None, prefix="", dry_run=False):
    
    if remotes is None:
        remotes, _ = _resources_files(
            abs_paths=remote_location.startswith('s3://'))
    if remote_location.startswith('s3://'):
        from .s3 import S3Backend
        backend = S3Backend(remote_location, dry_run=dry_run)
        backend.download(list_local(remotes, prefix), prefix)
    else:
        dest_root = '.'
        shell_command([
                '/usr/bin/rsync',
                '-thrRvz', '--rsync-path', '/usr/bin/rsync',
                '%s/./' % remote_location, dest_root], dry_run=dry_run)
640435
def get_remote_file(self, remote_path, local_path):
        
        sftp_client = self.transport.open_sftp_client()
        LOG.debug('Get the remote file. '
                  'Source=%(src)s. Target=%(target)s.' %
                  {'src': remote_path, 'target': local_path})
        try:
            sftp_client.get(remote_path, local_path)
        except Exception as ex:
            LOG.error('Failed to secure copy. Reason: %s.' %
                      six.text_type(ex))
            raise SFtpExecutionError(err=ex)
1190795
def pull_from_origin(repo_path):
    """"""
    LOG.info("Pulling from origin at %s." % repo_path)
    command = GIT_PULL_CMD.format(repo_path)
    resp = envoy.run(command)
    if resp.status_code != 0:
        LOG.exception("Pull failed.")
        raise GitException(resp.std_err)
    else:
        LOG.info("Pull successful.")
1311521
def handle_git_pillar(self):
        '''
        
        '''
        try:
            for pillar in self.git_pillar:
                pillar.fetch_remotes()
        except Exception as exc:
            log.error('Exception caught while updating git_pillar',
                      exc_info=True)
365844
def root_sync(args, l, config):
    
    from requests.exceptions import ConnectionError

    all_remote_names = [ r.short_name for r in l.remotes ]

    if args.all:
        remotes = all_remote_names
    else:
        remotes = args.refs

    prt("Sync with {} remotes or bundles ".format(len(remotes)))

    if not remotes:
        return

    for ref in remotes:
        l.commit()

        try:
            if ref in all_remote_names: # It's a remote name
                l.sync_remote(l.remote(ref))

            else: # It's a bundle reference

                l.checkin_remote_bundle(ref)

        except NotFoundError as e:
            warn(e)
            continue
        except ConnectionError as e:
            warn(e)
            continue
84843
def scp_file_remote_to_local(self, remote_path, local_path):
        

        sshadd_command = [
            'ssh-add',
            '/Users/pyrat/.ssh/ubuntuNode'
        ]
        self.info_log(
            "executing command: %s" %
            ' '.join(sshadd_command)
        )
        p = subprocess.Popen(sshadd_command)
        p.wait()

        scp_command = [
            'scp',
            '-o',
            'StrictHostKeyChecking=no',
            '%s@%s:"%s"' %
            (
                self.browser_config.get('username'),
                self.get_ip(),
                remote_path
            ),
            local_path
        ]
        self.info_log(
            "executing command: %s" %
            ' '.join(scp_command)
        )
        p = subprocess.Popen(scp_command)
        p.wait()
527662
def get_remote_revision(url, branch):
    
    proc = Process("git remote revision", ["git", "ls-remote", url, "refs/heads/" + branch])

    try:
        while True:
            raw_line = proc.stdout.pop()
            line = raw_line.strip().decode('utf8')
            if not line:
                continue
            return line.split("\t")[0]
    finally:
        try:
            proc.join()
        except Exception:
            pass