本文整理汇总了Python中vcstools.git.GitClient._do_update方法的典型用法代码示例。如果您正苦于以下问题:Python GitClient._do_update方法的具体用法?Python GitClient._do_update怎么用?Python GitClient._do_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcstools.git.GitClient
的用法示例。
在下文中一共展示了GitClient._do_update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_file
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import _do_update [as 别名]
def _get_file(self, repo_type, repo_url, version, filename):
""" Fetch the file specificed by filename relative to the root of the repository"""
name = simplify_repo_name(repo_url)
repo_path = os.path.join(self._cache_location, name)
#client = VcsClient(repo_type, repo_path)
client = GitClient(repo_path) # using git only
updated = False
if client.path_exists():
if client.get_url() == repo_url:
if not self._skip_update:
updated = client.update(version, force_fetch=True)
else:
updated = client._do_update(version)
if not updated:
shutil.rmtree(repo_path)
if not updated:
updated = client.checkout(repo_url, version, shallow=True)
if not updated:
raise VcsError("Impossible to update/checkout repo '%s' with version '%s'." % (repo_url, version))
full_filename = os.path.join(repo_path, filename)
if not os.path.exists(full_filename):
raise VcsError("Requested file '%s' missing from repo '%s' version '%s' (viewed at version '%s'). It was expected at: %s" %
(filename, repo_url, version, client.get_version(), full_filename))
return full_filename
示例2: _get_file
# 需要导入模块: from vcstools.git import GitClient [as 别名]
# 或者: from vcstools.git.GitClient import _do_update [as 别名]
def _get_file(self, _repo_type, repo_url, version, filename):
""" Fetch the file specificed by filename relative to the root of the repository"""
name = simplify_repo_name(repo_url)
repo_path = os.path.join(self._cache_location, name)
client = GitClient(repo_path) # using git only
updated = False
if client.path_exists():
if client.get_url() == repo_url:
if not self._skip_update:
logging.disable(logging.WARNING)
updated = client.update(version, force_fetch=True)
logging.disable(logging.NOTSET)
else:
try: # catch exception which can be caused by calling internal API
logging.disable(logging.WARNING)
updated = client._do_update(version)
logging.disable(logging.NOTSET)
except GitError:
updated = False
if not updated:
shutil.rmtree(repo_path)
if not updated:
logging.disable(logging.WARNING)
updated = client.checkout(repo_url, version)
logging.disable(logging.NOTSET)
if not updated:
raise VcsError("Impossible to update/checkout repo '%s' with version '%s'." % (repo_url, version))
full_filename = os.path.join(repo_path, filename)
if not os.path.exists(full_filename):
raise VcsError("Requested file '%s' missing from repo '%s' version '%s' (viewed at version '%s'). It was expected at: %s" %
(filename, repo_url, version, client.get_version(), full_filename))
return full_filename