当前位置: 首页>>代码示例>>Python>>正文


Python Repo.create_remote方法代码示例

本文整理汇总了Python中git.Repo.create_remote方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.create_remote方法的具体用法?Python Repo.create_remote怎么用?Python Repo.create_remote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git.Repo的用法示例。


在下文中一共展示了Repo.create_remote方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: feedstocks_clone_all_handle_args

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
def feedstocks_clone_all_handle_args(args):
    for repo in feedstock_repos(args.organization):
        clone_directory = os.path.join(args.feedstocks_directory, repo.name)
        if not os.path.exists(clone_directory):
            print('Cloning {}'.format(repo.name))
            new_repo = Repo.clone_from(repo.ssh_url, clone_directory)
        clone = Repo(clone_directory)
        if 'upstream' in [remote.name for remote in clone.remotes]:
            clone.delete_remote('upstream')
        clone.create_remote('upstream', url=repo.ssh_url)
开发者ID:TomAugspurger,项目名称:conda-smithy,代码行数:12,代码来源:feedstocks.py

示例2: clone_feedstock

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
def clone_feedstock(feedstock_gh_repo, feedstocks_dir):
    repo = feedstock_gh_repo

    clone_directory = os.path.join(feedstocks_dir, repo.name)
    if not os.path.exists(clone_directory):
        print('Cloning {}'.format(repo.name))
        new_repo = Repo.clone_from(repo.ssh_url, clone_directory)
    clone = Repo(clone_directory)
    if 'upstream' in [remote.name for remote in clone.remotes]:
        clone.delete_remote('upstream')
    clone.create_remote('upstream', url=repo.ssh_url)
开发者ID:bollwyvl,项目名称:conda-smithy,代码行数:13,代码来源:feedstocks.py

示例3: update_data

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
def update_data(repo: Repo, repo_addr: str):
    """Updates given git repo.

    Args:
        repo: Git data repo.
        repo_addr: url address of the repo
    """
    logging.info(f'Updating repo in {repo.working_dir}')
    if 'origin' not in [r.name for r in repo.remotes]:
        repo.create_remote('origin', repo_addr)
    repo.remotes.origin.fetch('+refs/heads/*:refs/remotes/origin/*')
    repo.remotes.origin.pull()
开发者ID:suttacentral,项目名称:suttacentral,代码行数:14,代码来源:arangoload.py

示例4: _open_repo

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
    def _open_repo(self, repo_dir, upstream_url):
        # Split things out into multiple steps and checks to be Ctrl-c resilient
        if os.path.isdir(repo_dir):
            repo = Repo(repo_dir)
        else:
            repo = Repo.init(repo_dir)

        try:
            repo.remotes.origin
        except AttributeError:
            repo.create_remote('origin', upstream_url)
        return repo
开发者ID:ministryofjustice,项目名称:opg-cotton,代码行数:14,代码来源:shaker.py

示例5: checkout

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
    def checkout(self, commit='master'):
        # If commit is none, we'll get the latest
        try:
            repo = Repo(self.local_path)
        except NoSuchPathError:
            # I guess it was never cloned...
            repo = Repo.init(self.local_path)
            repo.create_remote('origin', url=self.url)

        repo.remotes.origin.fetch()
        bare_master = repo.create_head('master', repo.remotes.origin.refs.master)
        repo.head.set_reference(bare_master)
        repo.head.reset(index=True, working_tree=True)
        return repo
开发者ID:csinchok,项目名称:lint-computer,代码行数:16,代码来源:models.py

示例6: fetch_clicked

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
    def fetch_clicked(self):
        """
            When the Fetch button is clicked, we fetch the remote references.
        """
        a_repo = Repo(self._directory)
        remote_url = unicode(self._ui.locationLineEdit.text())
        if remote_url in self._existing_remotes:
            self._remote = a_repo.remotes[self._existing_remotes[remote_url]]
        else:
            id = 0
            available_name = "remote" + str(id)
            while available_name in self._existing_remotes.values():
                id += 1
                available_name = "remote" + str(id)
            self._remote = a_repo.create_remote(available_name, remote_url)
            self._remote.fetch()
            self._created_remotes.append(self._remote)

        # When fetching a second time, we will only have the branches
        fetch_refs = self._remote.fetch()
        self._ui.branchComboBox.clear()
        for fetch_info in fetch_refs:
            self._ui.branchComboBox.insertItem(0, fetch_info.name)
        self._ui.branchComboBox.insertItem(0, QString(""))
        self._ui.branchComboBox.setCurrentIndex(0)

        self.branch_mode()
开发者ID:mike-perdide,项目名称:gitbuster,代码行数:29,代码来源:remote_branch_dialog.py

示例7: rebase

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
    def rebase(self, issue, branch=None):
        if not issue.pull_request:
            return "Rebase is just supported in PR for now"

        pr = issue.repository.get_pull(issue.number)

        branch_name = pr.head.ref
        branched_sdk_id = pr.head.repo.full_name+'@'+branch_name

        upstream_url = 'https://github.com/{}.git'.format(pr.base.repo.full_name)
        upstream_base = pr.base.ref if not branch else branch

        with tempfile.TemporaryDirectory() as temp_dir, \
                manage_git_folder(self.gh_token, Path(temp_dir) / Path("sdk"), branched_sdk_id) as sdk_folder:

            sdk_repo = Repo(str(sdk_folder))
            configure_user(self.gh_token, sdk_repo)

            upstream = sdk_repo.create_remote('upstream', url=upstream_url)
            upstream.fetch()

            msg = sdk_repo.git.rebase('upstream/{}'.format(upstream_base))
            _LOGGER.debug(msg)
            msg = sdk_repo.git.push(force=True)
            _LOGGER.debug(msg)

            return "Rebase done and pushed to the branch"
开发者ID:lmazuel,项目名称:swagger-to-sdk,代码行数:29,代码来源:sdkbot.py

示例8: _initialise_git_repo

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
    def _initialise_git_repo(self):
        '''
        Get a fresh initialised Repo object
        '''
        repo = Repo(str(self._staging_git_path))
        main_remote = repo.remotes[self.REMOTE_NAME]

        if main_remote.exists():
            config_writer = main_remote.config_writer
            config_writer.set('url', self._git_uri)
            config_writer.release()
        else:
            repo.create_remote(self.REMOTE_NAME, self._git_uri)

        self.log.debug('Initialise with repo: %r', repo)
        return repo
开发者ID:cscutcher,项目名称:homeslick,代码行数:18,代码来源:castle.py

示例9: commit

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
def commit(repo_path, remote_repo_url, remote_repo_name):
    try:
        repo = Repo(repo_path, odbt=GitCmdObjectDB)
        #repo.index.add(crawl_paths)
    except InvalidGitRepositoryError:
        #FIXME: try clone first
        repo = Repo.init(repo_path)
    try:
        origin = repo.remotes[remote_repo_name]
    except IndexError:
        origin = repo.create_remote(remote_repo_name, remote_repo_url)

    logger.debug('repo working dir %s' % repo.working_dir)

    #with repo.git.custom_environment(GIT_SSH=GIT_SSH_COMMAND):
    origin.pull(RULES_REPO_BRANCH)

    repo.index.add('*')
    logger.debug('added files to repo')
    commit_msg = "Crawl completed at " + time.strftime("%Y-%m-%d-%H-%M-%S")
    environ["GIT_AUTHOR_NAME"] = GIT_AUTHOR_NAME
    environ["GIT_AUTHOR_EMAIL"] = GIT_AUTHOR_EMAIL
    committed = repo.index.commit(commit_msg)
    logger.debug('commited policy data')
    logger.debug(committed)

    #with repo.git.custom_environment(GIT_SSH=GIT_SSH_COMMAND):
    origin.push(RULES_REPO_BRANCH)
开发者ID:juga0,项目名称:page-watcher-code,代码行数:30,代码来源:page_watcher.py

示例10: clone

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
    def clone(self):
        if not os.path.exists(self.build_dir):
            print(green('Cloning %s into %s' % (self.origin, self.build_dir)))
            repo = Repo.init(self.build_dir)
            repo.create_remote('origin', self.origin)
        else:
            print(green('Fetch updates for %s' % self.build_dir))
            repo = Repo(self.build_dir)
            if repo.remotes.origin.url != self.origin:  # update remote if desired
                repo.delete_remote(repo.remotes.origin)
                repo.create_remote('origin', self.origin)
            repo.git.checkout('master', f=True)

        repo.remotes.origin.fetch(tags=True)
        repo.remotes.origin.pull('master')
        return repo
开发者ID:mathiasertl,项目名称:fabric-webbuilders,代码行数:18,代码来源:base.py

示例11: Pull_git

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
def Pull_git():
    try:
        logging.info( 'Trying to initialize btcnet_info repo')
        repo = Repo("btcnet_info")
        try:
            logging.info('Checking if it has been cloned properly')
            repo = repo.clone_from("git://github.com/c00w/btcnet_info.git", 'btcnet_info')
        except git.exc.GitCommandError:
            logging.info('It has been cloned properly')
            
    except git.exc.GitCommandError:
        logging.info( 'Making new btcnet_info repo')
        repo = Repo.init("btcnet_info")
        logging.info('Cloning into it')
        repo = repo.clone_from("git://github.com/c00w/btcnet_info.git", 'btcnet_info')
        try:
            logging.info('Checking if we need to add the origin')
            origin = repo.create_remote('origin', 'git://github.com/c00w/btcnet_info.git')
        except git.exc.GitCommandError:
            logging.info('We do not need to add the origin')
        
    logging.info( 'Updating btcnet_info')
    origin = repo.remotes.origin
    origin.fetch()
    origin.pull('master')
    logging.info( 'Done')
开发者ID:callmeivan,项目名称:bitHopper,代码行数:28,代码来源:btcnet_wrapper.py

示例12: Pull_git

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
def Pull_git():
    """
    Tries to load btcnet_info as git repository and download the files
    """
    try:
        logging.info('Trying to load btcnet_info submodule')
        #Try load load btcnet_info as a git repo (Submodule)
        repo = Repo("btcnet_info")
    except GitCommandError:
        # Here we have some sort of error probably an empty directory in a zip download instead of 
        # A git submodule
        logging.info('Making new btcnet_info repo')
        repo = Repo.init("btcnet_info")
        logging.info('Cloning into it')
        repo = repo.clone_from("git://github.com/c00w/btcnet_info.git", 'btcnet_info')
        try:
            #For some reason the above doesn't always set the origin correctly.
            logging.info('Checking if we need to add the origin')
            origin = repo.create_remote('origin', 'git://github.com/c00w/btcnet_info.git')
        except GitCommandError:
            logging.info('We do not need to add the origin')
        
        
    logging.info('Updating btcnet_info')
    #Select the origin
    origin = repo.remotes.origin
    #Update it
    origin.fetch()
    #Pull the master branch
    origin.pull('master')
    logging.info('Done')
开发者ID:buttcoin,项目名称:bitHopper,代码行数:33,代码来源:btcnet_wrapper.py

示例13: add_remote

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
    def add_remote(cls, repo: Repo,
                   remote_git_url: str, remote_name: str=None):
        remote_name = remote_name or "origin"
        if cls._get_remote(repo, remote_name):
            log.warn("Repeatedly adding remote: {}".format(remote_name))
            return

        return repo.create_remote(remote_name, remote_git_url)
开发者ID:asamalik,项目名称:cdic,代码行数:10,代码来源:git.py

示例14: create_github_repo

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
def create_github_repo(args):
    token = gh_token()
    meta = configure_feedstock.meta_of_feedstock(args.feedstock_directory)

    from git import Repo

    gh = Github(token)
    if args.user is not None:
        pass
        # User has been defined, and organization has not.
        user_or_org = gh.get_user()
    else:
        # Use the organization provided.
        user_or_org = gh.get_organization(args.organization)

    repo_name = os.path.basename(os.path.abspath(args.feedstock_directory))
    try:
        gh_repo = user_or_org.create_repo(
            repo_name, has_wiki=False, description="A conda-smithy repository for {}.".format(meta.name())
        )
        print("Created {} on github".format(gh_repo.full_name))
    except GithubException as gh_except:
        if gh_except.data.get("errors", [{}])[0].get("message", "") != u"name already exists on this account":
            raise
        gh_repo = user_or_org.get_repo(repo_name)
        print("Github repository already exists.")

    # Now add this new repo as a remote on the local clone.
    repo = Repo(args.feedstock_directory)
    remote_name = args.remote_name.strip()
    if remote_name:
        if remote_name in [remote.name for remote in repo.remotes]:
            existing_remote = repo.remotes[remote_name]
            if existing_remote.url != gh_repo.ssh_url:
                print(
                    "Remote {} already exists, and doesn't point to {} "
                    "(it points to {}).".format(remote_name, gh_repo.ssh_url, existing_remote.url)
                )
        else:
            repo.create_remote(remote_name, gh_repo.ssh_url)
开发者ID:janschulz,项目名称:conda-smithy,代码行数:42,代码来源:github.py

示例15: run

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_remote [as 别名]
    def run(self):
        os.seteuid(0)
        os.setgid(self.gid)
        os.setuid(self.uid)

        # In case of nonexistent path or empty directory clone the repository.
        # Otherwise open it.
        try:
            if not os.path.exists(self.local) or not os.listdir(self.local):
                os.umask(0022)
                logger.info("Cloning repo '%s' from '%s' to '%s'" % (self.name, self.remote, self.local))
                repo = Repo.clone_from(self.remote, self.local)
            else:
                logger.info("Loading repo '%s' at '%s'" % (self.name, self.local))
                repo = Repo(self.local)

            # To make sure our remote is up to date, we delete and create it 
            # again.
            if 'watchgit' in [remote.name for remote in repo.remotes]:
                logger.debug("Deleting remote 'watchgit' from repository '%s'" % self.name)
                repo.delete_remote('watchgit')

            logger.debug("Creating remote '%s' on repository '%s'" % (self.remote, self.name))
            remotes = [repo.create_remote('watchgit', self.remote)]
            
            # if all_remotes is set we pull from all remotes
            if self.all_remotes is True:
                remotes = repo.remotes

        # If skip_on_error is true, we don't need to raise a fatal exception.
        # Instead we signal our watcher with the exitcode that we failed while
        # trying to load the repo.
        except Exception as e:
            if self.skip_on_error is True:
                logger.warn(e, exc_info=1)
                os._exit(128)
            else:
                raise

        # Start the watch
        logger.info("Starting watch of repository at '%s'" % repo.working_dir)
        while True:
            logger.debug("Pulling ref '%s' for '%s'" % (self.ref, repo.working_dir))
            if self.reset is True and repo.is_dirty():
                logger.info("Resetting dirty repository at '%s'" % repo.working_dir)
                repo.head.reset(working_tree=True)
            for remote in remotes:
                logger.debug("Pulling remote '%s'", remote.name)
                remote.pull(self.ref)

            time.sleep(self.interval)
开发者ID:tdevelioglu,项目名称:watchgit,代码行数:53,代码来源:watchgit.py


注:本文中的git.Repo.create_remote方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。