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


Python Repo.remote方法代码示例

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


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

示例1: git_pull

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
    def git_pull(self, name, source):
        """
        Pull the plugin from  git repository.

        :param name: Plugin name.
        :param source: Source url.
        :returns: ``True`` if successful.
        :rtype: bool
        """
        target_dir = join(self.path, "plugins", name)
        try:
            repo = Repo(target_dir)
            try:
                repo.remote().pull()
                self.print("pulled '{}' from '{}'".format(name, source))
                return True
            except RepositoryDirtyError:
                self.print("WARNING: Repository for plugin '{}' is dirty.".format(name))
                return True
            except UnmergedEntriesError:
                self.print("WARNING: Repository for plugin '{}' has unmerged changes.".format(name))
                return True
        except InvalidGitRepositoryError:
            # This is an invalid git repository. Clone it.
            return self.git_clone(name, source)
开发者ID:aarondewindt,项目名称:urban-journey,代码行数:27,代码来源:__init__.py

示例2: update_submodule

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def update_submodule():
    output_repo = Repo(full_path(publishconf.OUTPUT_PATH))
    output_repo.remote("origin").pull("master")

    repo = Repo(blog_path)
    if any(x for x in repo.index.diff(None) if normpath(x.a_path) == normpath(publishconf.OUTPUT_PATH)):
        logging.warn("Updating submodule to latest version")
        repo.git.add(publishconf.OUTPUT_PATH)
        repo.index.commit(message="Updated output to latest version in remote")
开发者ID:t-redactyl,项目名称:blog,代码行数:11,代码来源:fabfile.py

示例3: update_buildout

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
    def update_buildout(self):
        """Commit the changes on buildout"""
        msg = 'Update buildout'
        logger.info(msg)
        logger.info('-' * len(msg))

        repo = Repo(os.path.curdir)
        repo.git.add('versions.cfg')
        repo.git.commit(message=self.commit_message)
        # push the changes
        repo.remote().push()
开发者ID:derFreitag,项目名称:freitag.releaser,代码行数:13,代码来源:release.py

示例4: print_about_page

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def print_about_page(ydk_root, py_api_doc_gen):
    repo = Repo(ydk_root)
    remote = repo.remote().name
    branch = repo.active_branch.name
    url = repo.remote().url.split('://')[-1].split('.git')[0]
    commit_id = repo.rev_parse(remote + '/' + branch).hexsha

    # modify about_ydk.rst page
    for line in fileinput.input(os.path.join(py_api_doc_gen, 'about_ydk.rst'), 'r+w'):
       if 'git clone repo-url' in line:
           print line.replace('repo-url', 'https://{0}.git'.format(url)),
       elif 'git checkout commit-id' in line:
           print line.replace('commit-id', '{}'.format(commit_id))
       else:
           print line,
开发者ID:siming85,项目名称:ydk-gen,代码行数:17,代码来源:generate.py

示例5: upload_pdf

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def upload_pdf(file_list, repo_path):
    repo = Repo(repo_path)
    commit_message = 'Add new pdf'
    repo.index.add(file_list)
    repo.index.commit(commit_message)
    origin = repo.remote('origin')
    origin.push('master')
开发者ID:robertkck,项目名称:world-control,代码行数:9,代码来源:module.py

示例6: update_repository

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def update_repository(path, branch, logger):
    try:
        repository = Repo(path)

        if repository.bare:
            logger.warn("\"%s\" is a bare git repository, skipping", path)
            return False

        if repository.is_dirty():
            logger.warn("\"%s\" has unsaved changes, skipping", path)
            return False

        branches = repository.branches
        # noinspection PyTypeChecker
        for b in branches:
            if b.name == branch:
                logger.info("Updating \"%s\"", path)
                b.checkout()
                origin = repository.remote()
                origin.pull()
                return True
            else:
                logger.info("\"%s\" does not have a %s branch, skipping", path, branch)
                return False
    except InvalidGitRepositoryError:
        logger.warn("\"%s\" is not a valid git repository, skipping", path)
        return False
    except GitCommandError:
        logger.exception("Failed to update \"%s\"", path)
        return False
开发者ID:ldalamagas,项目名称:git-puller,代码行数:32,代码来源:shell.py

示例7: print_about_ydk_page

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def print_about_ydk_page(ydk_root, py_api_doc_gen):
    repo = Repo(ydk_root)
    remote = repo.remote().name
    branch = repo.active_branch.name
    url = repo.remote().url.split('://')[-1].split('.git')[0]
    commit_id = repo.rev_parse(remote + '/' + branch).hexsha

    contents = ''

    with open(os.path.join(py_api_doc_gen, 'about_ydk.rst'), 'r+w') as about_file:
        contents = about_file.read()
        contents = contents.replace('git clone repo-url', 'git clone https://{0}.git'.format(url))
        contents = contents.replace('git checkout commit-id', 'git checkout {0}'.format(commit_id))

    with open(os.path.join(py_api_doc_gen, 'about_ydk.rst'), 'w') as about_file:
        about_file.write(contents)
开发者ID:ReignInChaos,项目名称:ydk-gen,代码行数:18,代码来源:generate.py

示例8: check_changes_to_be_released

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
    def check_changes_to_be_released(self):
        """Check which distributions have changes that could need a release"""
        logger.info('')
        msg = 'Check changes to be released'
        logger.info(msg)
        logger.info('-' * len(msg))
        need_a_release = []
        for distribution_path in self.distributions:
            dist_name = distribution_path.split('/')[-1]
            logger.debug(DISTRIBUTION.format(distribution_path))
            repo = Repo(distribution_path)
            remote = repo.remote()

            latest_tag = get_latest_tag(repo, self.branch)
            if latest_tag not in repo.tags:
                # if there is no tag it definitely needs a release
                need_a_release.append(distribution_path)
                self.last_tags[dist_name] = latest_tag
                continue

            self.last_tags[dist_name] = latest_tag
            # get the commit where the latest tag is on
            tag = repo.tags[latest_tag]
            tag_sha = tag.commit.hexsha

            branch_sha = remote.refs[self.branch].commit.hexsha
            if tag_sha != branch_sha:
                # self.branch is ahead of the last tag: needs a release
                need_a_release.append(distribution_path)

        # if nothing is about to be released, do not filter the distributions
        if not self.test:
            self.distributions = need_a_release
开发者ID:derFreitag,项目名称:freitag.releaser,代码行数:35,代码来源:release.py

示例9: update_repo

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def update_repo(directory):
    """Update a repository.

    Returns:
        False if bad repository.
        True if everything worked.
    """
    log = logging.getLogger(__name__)

    try:
        repo = Repo(directory)
        current = {ref: ref.commit for ref in repo.refs}

        click.secho('Updating {0}'.format(repo.git_dir), fg='blue')

        remote = repo.remote()
        fetch_info_list = remote.pull()
    except InvalidGitRepositoryError:
        log.warning('%s is not a valid repository.', directory)
        return False
    except ValueError:
        log.warning('Check remotes for %s: %s', directory, repo.remotes)
        return False
    except GitCommandError as error:
        log.fatal('Pull failed. %s', error)
        return False

    check_changes(current, fetch_info_list, repo.branches)

    return True
开发者ID:e4r7hbug,项目名称:git_update,代码行数:32,代码来源:actions.py

示例10: CloneOrPull

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def CloneOrPull():
  r = None
  if not os.path.isdir("parts-repo"):
    r = Repo.clone_from("https://github.com/rcbuild-info/parts.git", "parts-repo")
  else:
    r = Repo("parts-repo")
  fetch_info = r.remote().pull()
开发者ID:freebs,项目名称:website,代码行数:9,代码来源:application.py

示例11: get_commit_if_possible

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def get_commit_if_possible(filename):
    """Try to retrieve VCS information for a given file.

    Currently only supports git using the gitpython package.

    Parameters
    ----------
    filename : str

    Returns
    -------
        path: str
            The base path of the repository
        commit: str
            The commit hash
        is_dirty: bool
            True if there are uncommitted changes in the repository
    """
    # git
    if opt.has_gitpython:
        from git import Repo, InvalidGitRepositoryError
        try:
            directory = os.path.dirname(filename)
            repo = Repo(directory, search_parent_directories=True)
            try:
                path = repo.remote().url
            except ValueError:
                path = 'git:/' + repo.working_dir
            is_dirty = repo.is_dirty()
            commit = repo.head.commit.hexsha
            return path, commit, is_dirty
        except InvalidGitRepositoryError:
            pass
    return None, None, None
开发者ID:elanmart,项目名称:sacred,代码行数:36,代码来源:dependencies.py

示例12: GitRepository

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
class GitRepository(object):
    def __init__(self, repo_path):
        self.path = repo_path
        self._pool = threadpool.ThreadPool(1, 2)
        self._pool.start()
        reactor.addSystemEventTrigger("before", "shutdown", self._pool.stop)
        self._repo = Repo(repo_path)

    def _deferToThread(self, func, *args, **kwargs):
        return threads.deferToThreadPool(reactor, self._pool, func, *args, **kwargs)

    @classmethod
    @defer.inlineCallbacks
    def clone(cls, url, dest):
        logger.msg("git.clone", url=url, dest=dest)
        yield threads.deferToThread(Repo.clone_from, url, dest, mirror=True)
        defer.returnValue(cls(dest))

    @defer.inlineCallbacks
    def update(self):
        remote = self._repo.remote("origin")
        yield self._deferToThread(remote.fetch)
        defer.returnValue(None)

    def last_commit(self, branch):
        for head in self._repo.heads:
            if head.name == branch:
                return head.commit
        else:
            raise NoSuchBranch(self, branch)
开发者ID:GaretJax,项目名称:ipd,代码行数:32,代码来源:repository.py

示例13: main

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def main(source, dest):
    """Rename a Git repository and update its remote accordingly."""
    basicConfig(level=DEBUG)
    try:
        repo = Repo(source)
    except OSError as error:
        logger.exception('Error:')
        exit(1)
    else:
        dest = Path(dest)
        try:
            dest = dest.with_suffix('.git')
        except ValueError:
            logger.exception('Error:')
            exit(1)
        logger.info('Using dest: %s', dest)

        remote = repo.remote()
        logger.debug('Old URL: %s', remote.url)
        origin = Path(remote.url)
        logger.debug('Parent: %s', origin.parent)

        new = origin.parent / dest
        logger.info('Using URL: %s', new)

        conf = remote.config_writer
        conf.set('url', str(new))
        conf.release()

        Path(source).rename(dest)
        exit(0)
开发者ID:NoviceLive,项目名称:unish,代码行数:33,代码来源:gmv.py

示例14: print_about_page

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def print_about_page(ydk_root, docs_rst_directory, release):
    repo = Repo(ydk_root)
    url = repo.remote().url.split('://')[-1].split('.git')[0]
    commit_id = str(repo.head.commit)

    if language == 'python':
        lang = 'py'
        code_block_language = 'sh'
    elif language in ('cpp', 'go') :
        lang = language
        code_block_language = 'bash'
    else:
        raise Exception('Language {0} not yet supported'.format(language))

    # modify about_ydk.rst page
    lines = ''
    with open(os.path.join(ydk_root, 'sdk/_docsgen_common/about_ydk.rst'), 'r+') as fd:
        lines = fd.read()
    if 'git clone repo-url' in lines:
        lines = lines.replace('repo-url', 'https://{0}.git'.format(url))
    if 'git checkout commit-id' in lines:
        lines = lines.replace('commit-id', '{}'.format(commit_id))
    if 'version-id' in lines:
        lines = lines.replace('version-id', '{}'.format(release.replace('release=', '')))
    if 'language-version' in lines:
        lines = lines.replace('language-version', lang)
    if 'code-block-language' in lines:
        lines = lines.replace('code-block-language', code_block_language)
    with open(os.path.join(docs_rst_directory, 'about_ydk.rst'), 'w+') as fd:
        fd.write(lines)
开发者ID:111pontes,项目名称:ydk-gen,代码行数:32,代码来源:generate.py

示例15: push_changes

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import remote [as 别名]
def push_changes():
    output_repo = Repo(full_path(publishconf.OUTPUT_PATH))

    if output_repo.is_dirty():
        # Adding untracked files
        output_repo.index.add(x for x in output_repo.untracked_files)

        # Adding modified files
        output_repo.index.add(x.a_path for x in output_repo.index.diff(None) if x.change_type == 'M')

        local("git --git-dir={0}/.git commit".format(output_repo.working_tree_dir))

        # Pushing output to master, publishing the blog
        output_repo.remote("origin").push("master")

    else:
        logging.info("No changes made to the blog!")
开发者ID:t-redactyl,项目名称:blog,代码行数:19,代码来源:fabfile.py


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