本文整理汇总了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