Updates a repository to the tip of `master`.  If the repository cannot
    be updated because a hook that is configured does not exist in `master`,
    this raises a RepositoryCannotBeUpdatedError

    Args:
        repo_config - A config for a repository
480696
def _update_repo(repo_config, store, tags_only):
    
    repo_path = store.clone(repo_config['repo'], repo_config['rev'])

    cmd_output('git', 'fetch', cwd=repo_path)
    tag_cmd = ('git', 'describe', 'origin/master', '--tags')
    if tags_only:
        tag_cmd += ('--abbrev=0',)
    else:
        tag_cmd += ('--exact',)
    try:
        rev = cmd_output(*tag_cmd, cwd=repo_path)[1].strip()
    except CalledProcessError:
        tag_cmd = ('git', 'rev-parse', 'origin/master')
        rev = cmd_output(*tag_cmd, cwd=repo_path)[1].strip()

    # Don't bother trying to update if our rev is the same
    if rev == repo_config['rev']:
        return repo_config

    try:
        path = store.clone(repo_config['repo'], rev)
        manifest = load_manifest(os.path.join(path, C.MANIFEST_FILE))
    except InvalidManifestError as e:
        raise RepositoryCannotBeUpdatedError(six.text_type(e))

    # See if any of our hooks were deleted with the new commits
    hooks = {hook['id'] for hook in repo_config['hooks']}
    hooks_missing = hooks - {hook['id'] for hook in manifest}
    if hooks_missing:
        raise RepositoryCannotBeUpdatedError(
            'Cannot update because the tip of master is missing these hooks:\n'
            '{}'.format(', '.join(sorted(hooks_missing))),
        )

    # Construct a new config with the head rev
    new_config = repo_config.copy()
    new_config['rev'] = rev
    return new_config
243690
def git_rebuild(repo, options = {})
      ensure_ready!(:authorization)
      url = "#{git_repo_path(repo)}/builds"
      api = connection(:api_format => :text)
      checked_response_body(api.post(url, options))
    end
1350312
def set_version(self, version, force=True):
        

        if version in self.versions:
            self._version = version
            if 'working' in self.repo.branch().stdout:
                if force:
                    logger.info('Found working branch. Removing...')
                    cmd = self.repo.checkout('master')
                    cmd = self.repo.branch('working', d=True)                    
                else:
                    logger.info('Found working branch from previous session. Use force=True to remove it and start anew.')
                    return

            stdout = self.repo.checkout(version, b='working').stdout  # active version set in 'working' branch
            logger.info('Version {0} set'.format(version))
        else:
            raise AttributeError('Version {0} not found'.format(version))
248675
def add(self, repo, url):
        
        repo_name = []
        if not url.endswith("/"):
            url = url + "/"
        for line in self.custom_repositories_list.splitlines():
            line = line.lstrip()
            if line and not line.startswith("#"):
                repo_name.append(line.split()[0])
        if (repo in self.meta.repositories or repo in repo_name or
                repo in self.meta.default_repositories):
            print("\nRepository name '{0}' exist, select different name.\n"
                  "View all repositories with command 'slpkg "
                  "repo-list'.\n".format(repo))
            raise SystemExit()
        elif len(repo) > 6:
            print("\nslpkg: Error: Maximum repository name length must be "
                  "six (6) characters\n")
            raise SystemExit()
        with open(self.custom_repo_file, "a") as repos:
            new_line = "  {0}{1}{2}\n".format(repo, " " * (10 - len(repo)), url)
            repos.write(new_line)
        repos.close()
        print("\nRepository '{0}' successfully added\n".format(repo))
        raise SystemExit()
1367769
def fill(self, config, section):
        
        if config.has_section(section):
            default_url = self.DEFAULT_REPOSITORIES.get(self.name, '')
            self.url = RepositoryURL(config_get(config, section, 'repository', default_url))
            self.username = config_get(config, section, 'username', '')
            self.password = config_get(config, section, 'password', '')
381823
def update_configs(self, release):
        
        git_repo = release['git_repo']
        git_cache = release['git_cache']
        if not os.path.isdir(git_cache):
            self.call(['git', 'clone', '--mirror', git_repo, git_cache])
        else:
            self.call(['git', 'fetch', '--all', '--prune'], cwd=git_cache)
        git_dir = release['git_dir'] = os.path.join(release['tmp_dir'],
                                                    os.path.basename(git_repo))
        self.call(['git', 'clone', '-b', release['git_branch'],
                   git_cache, git_dir])

        if release['delete_repo_files']:
            for repo_file in glob.glob(os.path.join(git_dir, '*.repo')):
                self.log.info('Deleting %s' % repo_file)
                os.unlink(repo_file)
87317
def remove(self, repo):
        
        rem_repo = False
        with open(self.custom_repo_file, "w") as repos:
            for line in self.custom_repositories_list.splitlines():
                repo_name = line.split()[0]
                if repo_name != repo:
                    repos.write(line + "\n")
                else:
                    print("\nRepository '{0}' successfully "
                          "removed\n".format(repo))
                    rem_repo = True
            repos.close()
        if not rem_repo:
            print("\nRepository '{0}' doesn't exist\n".format(repo))
        raise SystemExit()
744834
async function renovateRepository(repoConfig) {
  let config = { ...repoConfig };
  logger.setMeta({ repository: config.repository });
  logger.info('Renovating repository');
  logger.trace({ config });
  let repoResult;
  try {
    await fs.ensureDir(config.localDir);
    logger.debug('Using localDir: ' + config.localDir);
    config = await initRepo(config);
    const { res, branches, branchList, packageFiles } = await processRepo(
      config
    );
    await ensureOnboardingPr(config, packageFiles, branches);
    await ensureMasterIssue(config, branches);
    await finaliseRepo(config, branchList);
    repoResult = processResult(config, res);
  } catch (err) /*  */ {
    const errorRes = await handleError(config, err);
    repoResult = processResult(config, errorRes);
  }
  await platform.cleanRepo();
  if (config.localDir && !config.persistRepoData) {
    await fs.remove(config.localDir);
  }
  logger.info('Finished repository');
  return repoResult;
}
898934
def set(self, repo):
        
        name = repo.name
        if name in self.__repositories \
           and self.__repositories[name].is_initialized:
            raise ValueError('Can not replace repositories that have been '
                             'initialized.')
        self.__repositories[name] = repo
913757
def get_repo_config(self, repo='default'):
        
        for repo_config in self.repositories:
            if repo_config.name == repo or repo_config.url in RepositoryURL(repo):
                return repo_config

        return None
755424
def getHook(self, repo_user, repo_name, hook_id):
        
        return self.api.makeRequest(
            ['repos', repo_user, repo_name, 'hooks', str(hook_id)],
            method='GET',
            )
1130082
def update_repository_configuration(id, external_repository=None, prebuild_sync=None):
    
    to_update_id = id

    rc_to_update = pnc_api.repositories.get_specific(id=to_update_id).content

    if external_repository is None:
        external_repository = rc_to_update.external_url
    else:
        rc_to_update.external_url = external_repository

    if prebuild_sync is not None:
        rc_to_update.pre_build_sync_enabled = prebuild_sync

    if not external_repository and prebuild_sync:
        logging.error("You cannot enable prebuild sync without external repository")
        return

    response = utils.checked_api_call(pnc_api.repositories, 'update', id=to_update_id, body=rc_to_update)
    if response:
        return response.content
339376
def commit():
    

    session_token = request.headers['session_token']
    repository    = request.headers['repository']

    #===
    current_user = have_authenticated_user(request.environ['REMOTE_ADDR'], repository, session_token)
    if current_user is False: return fail(user_auth_fail_msg)

    #===
    repository_path = config['repositories'][repository]['path']

    def with_exclusive_lock():
        if not varify_user_lock(repository_path, session_token): return fail(lock_fail_msg)

        #===
        data_store = versioned_storage(repository_path)
        if not data_store.have_active_commit(): return fail(no_active_commit_msg)

        result = {}
        if request.headers['mode'] == 'commit':
            new_head = data_store.commit(request.headers['commit_message'], current_user['username'])
            result = {'head' : new_head}
        else:
            data_store.rollback()

        # Release the user lock
        update_user_lock(repository_path, None)
        return success(result)
    return lock_access(repository_path, with_exclusive_lock)
2060
def command_repo_add(self):
        
        if len(self.args) == 3 and self.args[0] == "repo-add":
            Repo().add(self.args[1], self.args[2])
        else:
            usage("")
512889
def git_update(repo, options = {})
      ensure_ready!(:authorization)
      response = connection.patch(git_repo_path(repo), options)
      checked_response_body(response)
    end
1328992
def update():
    '''
    
    '''
    # data for the fileserver event
    data = {'changed': False,
            'backend': 'hgfs'}
    # _clear_old_remotes runs init(), so use the value from there to avoid a
    # second init()
    data['changed'], repos = _clear_old_remotes()
    for repo in repos:
        if os.path.exists(repo['lockfile']):
            log.warning(
                'Update lockfile is present for hgfs remote %s, skipping. '
                'If this warning persists, it is possible that the update '
                'process was interrupted. Removing %s or running '
                '\'salt-run fileserver.clear_lock hgfs\' will allow updates '
                'to continue for this remote.', repo['url'], repo['lockfile']
            )
            continue
        _, errors = lock(repo)
        if errors:
            log.error(
                'Unable to set update lock for hgfs remote %s, skipping.',
                repo['url']
            )
            continue
        log.debug('hgfs is fetching from %s', repo['url'])
        repo['repo'].open()
        curtip = repo['repo'].tip()
        try:
            repo['repo'].pull()
        except Exception as exc:
            log.error(
                'Exception %s caught while updating hgfs remote %s',
                exc, repo['url'], exc_info_on_loglevel=logging.DEBUG
            )
        else:
            newtip = repo['repo'].tip()
            if curtip[1] != newtip[1]:
                data['changed'] = True
        repo['repo'].close()
        clear_lock(repo)

    env_cache = os.path.join(__opts__['cachedir'], 'hgfs/envs.p')
    if data.get('changed', False) is True or not os.path.isfile(env_cache):
        env_cachedir = os.path.dirname(env_cache)
        if not os.path.exists(env_cachedir):
            os.makedirs(env_cachedir)
        new_envs = envs(ignore_cache=True)
        serial = salt.payload.Serial(__opts__)
        with salt.utils.files.fopen(env_cache, 'wb+') as fp_:
            fp_.write(serial.dumps(new_envs))
            log.trace('Wrote env cache data to %s', env_cache)

    # if there is a change, fire an event
    if __opts__.get('fileserver_events', False):
        event = salt.utils.event.get_event(
                'master',
                __opts__['sock_dir'],
                __opts__['transport'],
                opts=__opts__,
                listen=False)
        event.fire_event(data, tagify(['hgfs', 'update'], prefix='fileserver'))
    try:
        salt.fileserver.reap_fileserver_cache_dir(
            os.path.join(__opts__['cachedir'], 'hgfs/hash'),
            find_file
        )
    except (IOError, OSError):
        # Hash file won't exist if no files have yet been served up
        pass
1180483
def commit(self, commit):
		
		try:
			return self._commitData(self.repo.commit(commit))
		except (ValueError, KeyError, BadObject):
			if self._repo_info:
				raise KeyError("Commit %s not found for %s" % (commit, str(self._repo_info)))
			else:
				raise KeyError("Commit %s not found" % commit)