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


Python Repo.clone_from方法代码示例

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


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

示例1: _clone_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
 def _clone_repo(repo_url):
     user_home = os.path.expanduser('~')
     # Assuming git url is of form [email protected]:user/git-repo.git
     repo_name = repo_url[repo_url.rfind('/') + 1: repo_url.rfind('.')]
     abs_local_path = os.path.join(user_home, repo_name)
     Repo.clone_from(repo_url, abs_local_path)
     return abs_local_path
开发者ID:bjoernbessert,项目名称:st2,代码行数:9,代码来源:download.py

示例2: _clone_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
    def _clone_repo(repo_url, verifyssl=True, branch='master'):
        user_home = os.path.expanduser('~')
        # Assuming git url is of form [email protected]:user/git-repo.git
        repo_name = repo_url[repo_url.rfind('/') + 1: repo_url.rfind('.')]
        abs_local_path = os.path.join(user_home, repo_name)

        # Disable SSL cert checking if explictly asked
        if not verifyssl:
            os.environ['GIT_SSL_NO_VERIFY'] = 'true'

        Repo.clone_from(repo_url, abs_local_path, branch=branch)
        return abs_local_path
开发者ID:bsyk,项目名称:st2,代码行数:14,代码来源:download.py

示例3: _clone_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
    def _clone_repo(repo_url, verifyssl=True, branch='master'):
        user_home = os.path.expanduser('~')
        # Assuming git url is of form [email protected]:user/git-repo.git
        repo_name = repo_url[repo_url.rfind('/') + 1: repo_url.rfind('.')]
        abs_local_path = os.path.join(user_home, repo_name)

        # Disable SSL cert checking if explictly asked
        if not verifyssl:
            os.environ['GIT_SSL_NO_VERIFY'] = 'true'
        # Shallow clone the repo to avoid getting all the metadata. We only need HEAD of a
        # specific branch so save some download time.
        Repo.clone_from(repo_url, abs_local_path, branch=branch, depth=1)
        return abs_local_path
开发者ID:ipv1337,项目名称:st2,代码行数:15,代码来源:download.py

示例4: _clone_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
    def _clone_repo(repo_url, verifyssl=True, branch="master"):
        user_home = os.path.expanduser("~")
        # Assuming git url is of form [email protected]:user/git-repo.git
        repo_name = DownloadGitRepoAction._eval_repo_name(repo_url)
        abs_local_path = os.path.join(user_home, repo_name)

        # Disable SSL cert checking if explictly asked
        if not verifyssl:
            os.environ["GIT_SSL_NO_VERIFY"] = "true"
        # Shallow clone the repo to avoid getting all the metadata. We only need HEAD of a
        # specific branch so save some download time.
        Repo.clone_from(repo_url, abs_local_path, branch=branch, depth=1)
        return abs_local_path
开发者ID:rlugojr,项目名称:st2,代码行数:15,代码来源:download.py

示例5: _clone_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
    def _clone_repo(temp_dir, repo_url, verifyssl=True, ref='master'):
        # Switch to non-interactive mode
        os.environ['GIT_TERMINAL_PROMPT'] = '0'
        os.environ['GIT_ASKPASS'] = '/bin/echo'

        # Disable SSL cert checking if explictly asked
        if not verifyssl:
            os.environ['GIT_SSL_NO_VERIFY'] = 'true'

        # Clone the repo from git; we don't use shallow copying
        # because we want the user to work with the repo in the
        # future.
        repo = Repo.clone_from(repo_url, temp_dir)
        use_branch = False

        # Try to match the reference to a branch name (i.e. "master")
        gitref = DownloadGitRepoAction._get_gitref(repo, "origin/%s" % ref)
        if gitref:
            use_branch = True

        # Try to match the reference to a commit hash, a tag, or "master"
        if not gitref:
            gitref = DownloadGitRepoAction._get_gitref(repo, ref)

        # Try to match the reference to a "vX.Y.Z" tag
        if not gitref and re.match(PACK_VERSION_REGEX, ref):
            gitref = DownloadGitRepoAction._get_gitref(repo, "v%s" % ref)

        # Giving up ¯\_(ツ)_/¯
        if not gitref:
            format_values = [ref, repo_url]
            msg = '"%s" is not a valid version, hash, tag or branch in %s.'

            valid_versions = DownloadGitRepoAction._get_valid_versions_for_repo(repo=repo)
            if len(valid_versions) >= 1:
                valid_versions_string = ', '.join(valid_versions)

                msg += ' Available versions are: %s.'
                format_values.append(valid_versions_string)

            raise ValueError(msg % tuple(format_values))

        # We're trying to figure out which branch the ref is actually on,
        # since there's no direct way to check for this in git-python.
        branches = repo.git.branch('-a', '--contains', gitref.hexsha)
        branches = branches.replace('*', '').split()
        if 'master' not in branches or use_branch:
            branch = "origin/%s" % ref if use_branch else branches[0]
            short_branch = ref if use_branch else branches[0].split('/')[-1]
            repo.git.checkout('-b', short_branch, branch)
            branch = repo.head.reference
        else:
            branch = 'master'

        repo.git.checkout(gitref.hexsha)
        repo.git.branch('-f', branch, gitref.hexsha)
        repo.git.checkout(branch)

        return temp_dir
开发者ID:Pulsant,项目名称:st2,代码行数:61,代码来源:download.py

示例6: _setup_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
    def _setup_repo(self, already_cloned):
        if already_cloned:
            self._git_repo = Repo(self.repo_dir_path)
        else:
            _log.info('Cloning repo from %s into %s' % (
                self._github_repo_url, self.repo_dir_path))
            self._git_repo = Repo.clone_from(
                self._github_repo_url, self.repo_dir_path)
            _log.info('-Done-')

        if self.branch:
            self._git_repo.git.checkout(self.branch)
开发者ID:patrickwestphal,项目名称:dl-learner-regression-stats,代码行数:14,代码来源:dllearnerrepo.py

示例7: __init__

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
    def __init__(self, database):
        logging.info("Initializing GitSync.")

        self.database = database
        self.charts = dict()
        self.url = DEFAULT_GITREPO

        try:
            self.repo = Repo(REPO_DIRECTORY)
        except InvalidGitRepositoryError:
            logging.info("Cloning repository in %s", REPO_DIRECTORY)
            self.repo = Repo.clone_from(self.url, REPO_DIRECTORY)
开发者ID:harbur,项目名称:elastickube,代码行数:14,代码来源:repo.py

示例8: _clone_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
    def _clone_repo(temp_dir, repo_url, verifyssl=True, ref='master'):
        # Switch to non-interactive mode
        os.environ['GIT_TERMINAL_PROMPT'] = '0'

        # Disable SSL cert checking if explictly asked
        if not verifyssl:
            os.environ['GIT_SSL_NO_VERIFY'] = 'true'

        # Clone the repo from git; we don't use shallow copying
        # because we want the user to work with the repo in the
        # future.
        repo = Repo.clone_from(repo_url, temp_dir)

        # Try to match the reference to a commit hash, a tag, or "master"
        gitref = DownloadGitRepoAction._get_gitref(repo, ref)

        # Try to match the reference to a "vX.Y.Z" tag
        if not gitref and re.match(SEMVER_REGEX, ref):
            gitref = DownloadGitRepoAction._get_gitref(repo, "v%s" % ref)

        # Try to match the reference to a branch name
        if not gitref:
            gitref = DownloadGitRepoAction._get_gitref(repo, "origin/%s" % ref)

        # Giving up ¯\_(ツ)_/¯
        if not gitref:
            raise ValueError(
                "\"%s\" is not a valid version, hash, tag, or branch in %s." % (ref, repo_url)
            )

        # We're trying to figure out which branch the ref is actually on,
        # since there's no direct way to check for this in git-python.
        branches = repo.git.branch('--color=never', '--all', '--contains', gitref.hexsha)
        branches = branches.replace('*', '').split()
        if 'master' not in branches:
            branch = branches[0]
            repo.git.checkout('--track', branches[0])
            branch = repo.head.reference
        else:
            branch = 'master'

        repo.git.checkout('-B', branch, gitref.hexsha)

        return temp_dir
开发者ID:LindsayHill,项目名称:st2,代码行数:46,代码来源:download.py

示例9: setup

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
    def setup(self):
        git_opts = self._config

        if git_opts['url'] is None:
            raise Exception('Remote git URL not set.')

        self._url = git_opts['url']
        default_clone_dir = os.path.join(os.path.dirname(__file__), 'clones')
        self._local_path = git_opts.get('local_clone_path', default_clone_dir)
        self._poll_interval = git_opts.get('poll_interval', self._poll_interval)

        if os.path.exists(self._local_path):
            self._repo = Repo.init(self._local_path)
        else:
            try:
                self._repo = Repo.clone_from(self._url, self._local_path)
            except Exception:
                self._logger.exception('Unable to clone remote repo from %s',
                                       self._url)
                raise

        self._remote = self._repo.remote('origin')
开发者ID:Gifflen,项目名称:st2contrib,代码行数:24,代码来源:git_commit_sensor.py

示例10: clone_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
 def clone_repo(self, name, path):
     Repo.clone_from("{}@{}:{}/{}.git".format(self.user,self.name,self.root,name),path)
开发者ID:ume-jean,项目名称:cfg,代码行数:4,代码来源:repo.py

示例11: clone_repo

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import clone_from [as 别名]
def clone_repo(temp_dir, repo_url, verify_ssl=True, ref='master'):
    # Switch to non-interactive mode
    os.environ['GIT_TERMINAL_PROMPT'] = '0'
    os.environ['GIT_ASKPASS'] = '/bin/echo'

    # Disable SSL cert checking if explictly asked
    if not verify_ssl:
        os.environ['GIT_SSL_NO_VERIFY'] = 'true'

    # Clone the repo from git; we don't use shallow copying
    # because we want the user to work with the repo in the
    # future.
    repo = Repo.clone_from(repo_url, temp_dir)

    is_local_repo = repo_url.startswith('file://')

    try:
        active_branch = repo.active_branch
    except TypeError as e:
        if is_local_repo:
            active_branch = None
        else:
            raise e

    # Special case for local git repos - we allow users to install from repos which are checked out
    # at a specific commit (aka detached HEAD)
    if is_local_repo and not active_branch and not ref:
        LOG.debug('Installing pack from git repo on disk, skipping branch checkout')
        return temp_dir

    use_branch = False

    # Special case when a default repo branch is not "master"
    # No ref provided so we just use a default active branch
    if (not ref or ref == active_branch.name) and repo.active_branch.object == repo.head.commit:
        gitref = repo.active_branch.object
    else:
        # Try to match the reference to a branch name (i.e. "master")
        gitref = get_gitref(repo, 'origin/%s' % ref)
        if gitref:
            use_branch = True

    # Try to match the reference to a commit hash, a tag, or "master"
    if not gitref:
        gitref = get_gitref(repo, ref)

    # Try to match the reference to a "vX.Y.Z" tag
    if not gitref and re.match(PACK_VERSION_REGEX, ref):
        gitref = get_gitref(repo, 'v%s' % ref)

    # Giving up ¯\_(ツ)_/¯
    if not gitref:
        format_values = [ref, repo_url]
        msg = '"%s" is not a valid version, hash, tag or branch in %s.'

        valid_versions = get_valid_versions_for_repo(repo=repo)
        if len(valid_versions) >= 1:
            valid_versions_string = ', '.join(valid_versions)

            msg += ' Available versions are: %s.'
            format_values.append(valid_versions_string)

        raise ValueError(msg % tuple(format_values))

    # We're trying to figure out which branch the ref is actually on,
    # since there's no direct way to check for this in git-python.
    branches = repo.git.branch('-a', '--contains', gitref.hexsha)  # pylint: disable=no-member
    branches = branches.replace('*', '').split()

    if active_branch.name not in branches or use_branch:
        branch = 'origin/%s' % ref if use_branch else branches[0]
        short_branch = ref if use_branch else branches[0].split('/')[-1]
        repo.git.checkout('-b', short_branch, branch)
        branch = repo.head.reference
    else:
        branch = repo.active_branch.name

    repo.git.checkout(gitref.hexsha)  # pylint: disable=no-member
    repo.git.branch('-f', branch, gitref.hexsha)  # pylint: disable=no-member
    repo.git.checkout(branch)

    return temp_dir
开发者ID:nzlosh,项目名称:st2,代码行数:84,代码来源:pack_management.py


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