format = args.format
if filename == '-':
- check_GNU_style_file(sys.stdin, None, format)
+ check_GNU_style_file(sys.stdin, format)
else:
- with open(filename, 'rb') as diff_file:
- check_GNU_style_file(diff_file, 'utf-8', format)
+ with open(filename, newline='\n') as diff_file:
+ check_GNU_style_file(diff_file, format)
main()
r = self.check.check('foo', 123, '\t a = 123;')
self.assertIsNone(r)
-def check_GNU_style_file(file, file_encoding, format):
+def check_GNU_style_file(file, format):
checks = [LineLengthCheck(), SpacesCheck(), TrailingWhitespaceCheck(),
SentenceSeparatorCheck(), SentenceEndOfCommentCheck(),
SentenceDotEndCheck(), FunctionParenthesisCheck(),
SpacesAndTabsMixedCheck()]
errors = []
- patch = PatchSet(file, encoding=file_encoding)
+ patch = PatchSet(file)
for pfile in patch.added_files + patch.modified_files:
t = pfile.target_file.lstrip('b/')
if not prs:
# if all ChangeLog entries have identical PRs
# then use them
- prs = self.changelog_entries[0].prs
- for entry in self.changelog_entries:
- if entry.prs != prs:
- prs = []
- break
+ if self.changelog_entries:
+ prs = self.changelog_entries[0].prs
+ for entry in self.changelog_entries:
+ if entry.prs != prs:
+ prs = []
+ break
entry = ChangeLogEntry(changelog_location,
self.top_level_authors,
prs)
class GitEmail(GitCommit):
def __init__(self, filename):
self.filename = filename
- diff = PatchSet.from_filename(filename)
+ diff = PatchSet.from_filename(filename, newline='\n')
date = None
author = None
subject = ''
filename = None
patch_lines = []
- with open(os.path.join(script_path, 'test_patches.txt')) as f:
+ with open(os.path.join(script_path, 'test_patches.txt'), newline='\n') as f:
lines = f.read()
for line in lines.split('\n'):
if line.startswith('==='):
def test_space_after_tab(self):
email = self.from_patch_glob('0001-Use-Value_Range-when-applying-inferred-ranges.patch')
assert (email.errors[0].message == 'extra space after tab')
+
+ def test_CR_in_patch(self):
+ email = self.from_patch_glob('0001-Add-M-character.patch')
+ assert (email.errors[0].message == 'cannot find a ChangeLog location in message')
if (r.intersect (infer.range (x)))
--
2.38.0
+
+=== 0001-Add-M-character.patch ====
+From 71ab4c18f279dc0fa0172ffe8cfac5fabcde953d Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Fri, 9 Dec 2022 11:55:21 +0100
+Subject: [PATCH] Add ^M character
+
+---
+ demo.txt | 5 +++++
+ 1 file changed, 5 insertions(+)
+ create mode 100644 demo.txt
+
+diff --git a/demo.txt b/demo.txt
+new file mode 100644
+index 0000000..d75da75
+--- /dev/null
++++ b/demo.txt
+@@ -0,0 +1,5 @@
++pub fn main ()
++{
++// { dg-error "Isolated CR" "" { target *-*-* } .+1 }
++ //! doc cr\r comment
++}
+--
+2.38.1
+
if args.directory:
root = args.directory
- data = open(args.input) if args.input else sys.stdin
+ data = open(args.input, newline='\n') if args.input else sys.stdin
if args.update_copyright:
update_copyright(data)
else: