当前位置: 首页>>代码示例>>Python>>正文


Python pygit2.GIT_SORT_TOPOLOGICAL属性代码示例

本文整理汇总了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)) 
开发者ID:FabriceSalvaire,项目名称:PySpice,代码行数:36,代码来源:git.py

示例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(),
        ) 
开发者ID:ibis-project,项目名称:ibis,代码行数:28,代码来源:genrelease.py

示例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] 
开发者ID:EmoteBot,项目名称:EmoteCollector,代码行数:6,代码来源:meta.py

示例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 
开发者ID:giovanifss,项目名称:Gitmails,代码行数:15,代码来源:git.py

示例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) 
开发者ID:vifactor,项目名称:repostat,代码行数:4,代码来源:gitdata.py

示例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 
开发者ID:vifactor,项目名称:repostat,代码行数:43,代码来源:gitdata.py


注:本文中的pygit2.GIT_SORT_TOPOLOGICAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。