本文整理汇总了Python中git.Repo.archive_tar_gz方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.archive_tar_gz方法的具体用法?Python Repo.archive_tar_gz怎么用?Python Repo.archive_tar_gz使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.archive_tar_gz方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyGitRepo
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import archive_tar_gz [as 别名]
class PyGitRepo(object):
def __init__(self, repo_path):
self.repo_obj = Repo(repo_path)
self.branches = [PyGitHead(branch) for branch in self.repo_obj.branches]
try:
self.owner = open(join(repo_path, 'owner')).read().strip()
except IOError:
self.owner = ""
@property
def last_change(self):
return self.latest_commits(1)[0]
def latest_commits(self, count=10):
try:
# Get the lastest COUNT commits
commits = self.repo_obj.git.rev_list(
all=True, max_count=count, date_order=True).split('\n')
except Exception as exc:
# If we fail, log it and return an empty list
log.exception(exc)
return []
# Create commits
return [self.commit(commit) for commit in commits]
return [PyGitCommit(Commit(self.repo_obj, commit)) for commit in commits]
def latest_tags(self, count=10):
try:
# Get the latest COUNT tags
tags = self.repo_obj.git.rev_list(tags=True, max_count=count,
no_walk=True, date_order=True).split('\n')
except Exception as exc:
log.exception(exc)
return []
return [PyGitTag(self.repo_obj, Tag(self.repo_obj.git.describe(tag), tag)) for tag in tags]
def commit(self, id):
# Get the commit object
commit_obj = self.repo_obj.commit(id)
# Generate the tags
tags = {}
for tag in self.repo_obj.tags:
if tag.commit.id == id:
tags[tag.commit.id] = PyGitTag(self.repo_obj, tag)
# Generate the heads
heads = [head for head in self.repo_obj.heads if head.commit.id == id]
# Return a generated commit
return PyGitCommit(commit_obj, tags=tags, heads=heads)
def tree(self, id):
# Get the tree object
tree_obj = self.repo_obj.tree(id)
return PyGitTree(tree_obj)
def blob(self, id):
# Get the blob object
blob_obj = Blob(self.repo_obj, id)
return PyGitBlob(blob_obj)
def archive_tar_gz(self, id):
return "application/x-compressed", self.repo_obj.archive_tar_gz(id)
def archive_tar_bz2(self, id):
from bz2 import compress
return "application/bzip2", compress(self.repo_obj.archive_tar(id))
def archive_zip(self, id):
return "application/zip", self.repo_obj.git.archive(id, format="zip")
@property
def description(self):
return self.repo_obj.description
def __repr__(self):
return "<PyGitRepo path='%s'>" % self.repo_obj.path