gcc-changelog: do not use PatchSet.from_filename
Use rather PatchSet constructor where we can pass properly opened file with newline='\n'. contrib/ChangeLog: * gcc-changelog/git_email.py: Use PatchSet constructor as newline argument is not supported with older unidiff library.
This commit is contained in:
parent
8f2a8be579
commit
66c2f03d4c
1 changed files with 4 additions and 7 deletions
|
@ -39,18 +39,15 @@ unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename')
|
|||
class GitEmail(GitCommit):
|
||||
def __init__(self, filename):
|
||||
self.filename = filename
|
||||
try:
|
||||
diff = PatchSet.from_filename(filename, newline='\n')
|
||||
except TypeError:
|
||||
# Older versions don't have the newline argument
|
||||
diff = PatchSet.from_filename(filename)
|
||||
date = None
|
||||
author = None
|
||||
subject = ''
|
||||
|
||||
subject_last = False
|
||||
with open(self.filename, 'r') as f:
|
||||
lines = f.read().splitlines()
|
||||
with open(self.filename, newline='\n') as f:
|
||||
data = f.read()
|
||||
diff = PatchSet(data)
|
||||
lines = data.splitlines()
|
||||
lines = list(takewhile(lambda line: line != '---', lines))
|
||||
for line in lines:
|
||||
if line.startswith(DATE_PREFIX):
|
||||
|
|
Loading…
Add table
Reference in a new issue