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


Python Commit.diff方法代码示例

本文整理汇总了Python中git.Commit.diff方法的典型用法代码示例。如果您正苦于以下问题:Python Commit.diff方法的具体用法?Python Commit.diff怎么用?Python Commit.diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git.Commit的用法示例。


在下文中一共展示了Commit.diff方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_files_changed_between_commits

# 需要导入模块: from git import Commit [as 别名]
# 或者: from git.Commit import diff [as 别名]
    def get_files_changed_between_commits(commit_a: Commit, commit_b: Commit)-> (Set[str], Set[str]):
        """Determine what files have been added or modified between commits b and a
        Those files should be added to a_files and if they are present in commit b,
        added to b_files

        :param commit_a:
        :param commit_b:
        :return: a pair of sets, the first set is the files in commit a
        the second set is the files in commit b
        ":rtype (Set[str], Set[str]):
        """

        diffs = commit_b.diff(other=commit_a)

        a_files = set()  # type: Set[str]
        b_files = set()  # type: Set[str]

        for diff in diffs:
            if diff.new_file or (diff.a_blob and diff.b_blob and diff.a_blob != diff.b_blob):
                a_files.add(diff.a_path)
                if not diff.new_file:
                    b_files.add(diff.b_path)

        return a_files, b_files
开发者ID:mkirby111,项目名称:lintable,代码行数:26,代码来源:git_handler.py


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