gcc-changelog/git_email.py: Support older unidiff modules

contrib/ChangeLog:

	* gcc-changelog/git_email.py: Add unidiff_supports_renaming check.
This commit is contained in:
Tobias Burnus 2020-11-03 17:46:36 +01:00
parent 19859d6ba6
commit 84ed8d2c88

View File

@ -24,10 +24,11 @@ from dateutil.parser import parse
from git_commit import GitCommit, GitInfo
from unidiff import PatchSet
from unidiff import PatchSet, PatchedFile
DATE_PREFIX = 'Date: '
FROM_PREFIX = 'From: '
unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename')
class GitEmail(GitCommit):
@ -58,7 +59,7 @@ class GitEmail(GitCommit):
t = 'A'
elif f.is_removed_file:
t = 'D'
elif f.is_rename:
elif unidiff_supports_renaming and f.is_rename:
# Consider that renamed files are two operations: the deletion
# of the original name and the addition of the new one.
modified_files.append((source, 'D'))