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


Python LocalGitClient.fetch方法代码示例

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


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

示例1: fetch

# 需要导入模块: from dulwich.client import LocalGitClient [as 别名]
# 或者: from dulwich.client.LocalGitClient import fetch [as 别名]
    def fetch(self, wire, url, apply_refs=True, refs=None):
        if url != 'default' and '://' not in url:
            client = LocalGitClient(url)
        else:
            url_obj = hg_url(url)
            o = self._build_opener(url)
            url, _ = url_obj.authinfo()
            client = HttpGitClient(base_url=url, opener=o)
        repo = self._factory.repo(wire)

        determine_wants = repo.object_store.determine_wants_all
        if refs:
            def determine_wants_requested(references):
                return [references[r] for r in references if r in refs]
            determine_wants = determine_wants_requested

        try:
            remote_refs = client.fetch(
                path=url, target=repo, determine_wants=determine_wants)
        except NotGitRepository:
            log.warning(
                'Trying to fetch from "%s" failed, not a Git repository.', url)
            raise exceptions.AbortException()

        # mikhail: client.fetch() returns all the remote refs, but fetches only
        # refs filtered by `determine_wants` function. We need to filter result
        # as well
        if refs:
            remote_refs = {k: remote_refs[k] for k in remote_refs if k in refs}

        if apply_refs:
            # TODO: johbo: Needs proper test coverage with a git repository
            # that contains a tag object, so that we would end up with
            # a peeled ref at this point.
            PEELED_REF_MARKER = '^{}'
            for k in remote_refs:
                if k.endswith(PEELED_REF_MARKER):
                    log.info("Skipping peeled reference %s", k)
                    continue
                repo[k] = remote_refs[k]

            if refs:
                # mikhail: explicitly set the head to the last ref.
                repo['HEAD'] = remote_refs[refs[-1]]

            # TODO: mikhail: should we return remote_refs here to be
            # consistent?
        else:
            return remote_refs
开发者ID:rhodecode,项目名称:rhodecode-vcsserver,代码行数:51,代码来源:git.py

示例2: test_fetch_into_empty

# 需要导入模块: from dulwich.client import LocalGitClient [as 别名]
# 或者: from dulwich.client.LocalGitClient import fetch [as 别名]
 def test_fetch_into_empty(self):
     c = LocalGitClient()
     t = MemoryRepo()
     s = open_repo('a.git')
     self.assertEquals(s.get_refs(), c.fetch(s.path, t))
开发者ID:imclab,项目名称:dulwich,代码行数:7,代码来源:test_client.py

示例3: test_fetch_into_empty

# 需要导入模块: from dulwich.client import LocalGitClient [as 别名]
# 或者: from dulwich.client.LocalGitClient import fetch [as 别名]
 def test_fetch_into_empty(self):
     c = LocalGitClient()
     t = MemoryRepo()
     s = open_repo('a.git')
     self.addCleanup(tear_down_repo, s)
     self.assertEqual(s.get_refs(), c.fetch(s.path, t).refs)
开发者ID:atbradley,项目名称:dulwich,代码行数:8,代码来源:test_client.py


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