本文整理汇总了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
示例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))
示例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)