本文整理汇总了Python中git.Repo.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.__init__方法的具体用法?Python Repo.__init__怎么用?Python Repo.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.__init__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import __init__ [as 别名]
def __init__(self, rid, rev='HEAD'):
Repo.__init__(self, os.path.join(settings.REPO_DIR, str(rid)))
# Store the repo id.
self.id = rid
try:
self.rev = self.commit(rev)
except BadObject:
if rev == 'HEAD':
self.rev = None
else:
raise
# Determine the owner.
if self.rev:
cr = self.config_reader('repository')
self.owner = {
'email': cr.get('user', 'email'),
'name': cr.get('user', 'name'),
}
else:
self.owner = None
# Determine what the main file is.
self.mainfile = None
self.files = [entry[0] for entry in self.index.entries.keys()]
if self.files:
self.files.remove('title')
self.mainfile = self.files[0]
# Determine the language of the main file.
self.language = None
if self.mainfile:
ext = '.' + self.mainfile.rsplit('.')[-1]
for lang in LANGUAGES.values():
if ext in lang['extensions']:
self.language = lang
break
# Get the commits.
if self.rev:
self.commits = [self.commit('HEAD')]
self.commits += [commit for commit in self.commits[0].iter_parents()]
else:
self.commits = []
self.has_history = len(self.commits) > 1
# Get the tags.
self.has_releases = len(self.tags) > 0
self.revtag = None
if self.rev:
for tag in self.tags:
if tag.commit == self.rev:
self.revtag = tag
break