本文整理汇总了Python中pygit2.GIT_SORT_TOPOLOGICAL属性的典型用法代码示例。如果您正苦于以下问题:Python pygit2.GIT_SORT_TOPOLOGICAL属性的具体用法?Python pygit2.GIT_SORT_TOPOLOGICAL怎么用?Python pygit2.GIT_SORT_TOPOLOGICAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pygit2
的用法示例。
在下文中一共展示了pygit2.GIT_SORT_TOPOLOGICAL属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_commits
# 需要导入模块: import pygit2 [as 别名]
# 或者: from pygit2 import GIT_SORT_TOPOLOGICAL [as 别名]
def get_commits(ctx):
path = '.'
repository_path = git.discover_repository(path)
# print(repository_path)
repository = git.Repository(repository_path)
head = repository.head
head_commit = repository[head.target]
# GIT_SORT_TOPOLOGICAL. Sort the repository contents in topological order (parents before children);
# this sorting mode can be combined with time sorting.
sorting = git.GIT_SORT_TOPOLOGICAL # git.GIT_SORT_TIME
commits = [commit for commit in repository.walk(head_commit.id, sorting)]
template = '''
====================================================================================================
{message}
-------------------------------------------------
{name} <{email}> / {timestamp}
{id}
'''
for commit in commits:
fields = {
'message': commit.message.strip(),
'id': commit.hex,
'timestamp': fromtimestamp(commit.commit_time).strftime('%Y-%m-%d %H:%M:%S'),
'name': commit.committer.name, # author
'email': commit.committer.email,
}
if 'salvaire' not in fields['name'].lower():
print(template.lstrip().format(**fields))
示例2: iter_release_notes
# 需要导入模块: import pygit2 [as 别名]
# 或者: from pygit2 import GIT_SORT_TOPOLOGICAL [as 别名]
def iter_release_notes(repo, from_ref, to_ref, default_role):
"""Yield release notes from `from_ref` to `to_ref`."""
pattern = re.compile(
r'^(?:{})\s+#(\d+)\s+from'.format('|'.join(GITHUB_CLOSE_KEYWORDS)),
flags=re.MULTILINE | re.IGNORECASE,
)
for commit in commits_between(
repo, from_ref, to_ref, options=pygit2.GIT_SORT_TOPOLOGICAL
):
message = commit.message.strip()
subject, *lines = map(str.strip, message.splitlines())
tag, *rest = subject.split(':', 1)
tag = tag.lower()
lineitem = ''.join(rest) or subject
role = KEYWORD_MAP.get(tag, default_role)
modifier = ' major' if role == 'bug' else ''
try:
issue_number, *_ = pattern.findall(message)
except ValueError:
issue_number = '-'
yield "* :{role}:`{issue_number}{modifier}` {lineitem}".format(
role=role,
issue_number=issue_number,
modifier=modifier,
lineitem=lineitem.strip(),
)
示例3: _current_revision
# 需要导入模块: import pygit2 [as 别名]
# 或者: from pygit2 import GIT_SORT_TOPOLOGICAL [as 别名]
def _current_revision(*, default='master'):
repo = pygit2.Repository('.git')
c = next(repo.walk(repo.head.target, pygit2.GIT_SORT_TOPOLOGICAL))
return c.hex[:10]
示例4: get_authors
# 需要导入模块: import pygit2 [as 别名]
# 或者: from pygit2 import GIT_SORT_TOPOLOGICAL [as 别名]
def get_authors(self, repo_path):
try:
if self.args.verbose:
Helpers.print_success("Collecting authors in {}".format(repo_path))
authors_set = set()
repo = Repository(repo_path)
for commit in repo.walk(repo.head.target, GIT_SORT_TOPOLOGICAL):
authors_set.add(Author(commit.author.name, commit.author.email))
return authors_set
except Exception as e:
Helpers.print_error("{}: Could not collect authors".format(repo_path))
return None
示例5: commits_walker
# 需要导入模块: import pygit2 [as 别名]
# 或者: from pygit2 import GIT_SORT_TOPOLOGICAL [as 别名]
def commits_walker(self):
return self.repo.walk(self.repo.head.target, git.GIT_SORT_TOPOLOGICAL)
示例6: fetch
# 需要导入模块: import pygit2 [as 别名]
# 或者: from pygit2 import GIT_SORT_TOPOLOGICAL [as 别名]
def fetch(self):
# TODO: this should perhaps be a part of WholeHistory
tag_refs = {refobj.peel().oid: refobj
for refobj in self.repo.listall_reference_objects() if refobj.name.startswith('refs/tags')}
result = []
tag_ref = None
is_symbolic_reference = False
for commit in self.repo.walk(self.repo.head.target, git.GIT_SORT_TOPOLOGICAL):
author_name, _ = map_signature(self.mailmap, commit.author)
if commit.oid in tag_refs:
tag_ref: git.Reference = tag_refs[commit.oid]
is_symbolic_reference = tag_ref.target.hex == commit.hex
if tag_ref is not None:
if not is_symbolic_reference:
tag = self.repo[tag_ref.target]
tagger_name, _ = map_signature(self.mailmap, tag.tagger)
tag_metadata = {
"tag_name": tag.name,
"tagger_name": tagger_name,
"tagger_time": tag.tagger.time,
}
else:
tag_metadata = {
"tag_name": tag_ref.shorthand,
"tagger_name": None,
"tagger_time": -1,
}
else:
tag_metadata = {
"tag_name": None,
"tagger_name": None,
"tagger_time": -1,
}
tag_metadata["commit_author"] = author_name
tag_metadata["commit_time"] = commit.author.time
tag_metadata["is_merge"] = len(commit.parents) > 1
result.append(tag_metadata)
return result