Skip to content

Commit 8ef1f48

Browse files
committed
Merge remote-tracking branch 'upstream-public/pr/2219' into development
2 parents 28efba0 + c117d59 commit 8ef1f48

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

tests/scripts/check-files.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ def check_file_for_issue(self, filepath):
4343
for i, line in enumerate(iter(f.readline, b"")):
4444
self.check_file_line(filepath, line, i + 1)
4545

46+
def record_issue(self, filepath, line_number):
47+
if filepath not in self.files_with_issues.keys():
48+
self.files_with_issues[filepath] = []
49+
self.files_with_issues[filepath].append(line_number)
50+
4651
def check_file_line(self, filepath, line, line_number):
4752
if self.issue_with_line(line):
48-
if filepath not in self.files_with_issues.keys():
49-
self.files_with_issues[filepath] = []
50-
self.files_with_issues[filepath].append(line_number)
53+
self.record_issue(filepath, line_number)
5154

5255
def output_file_issues(self, logger):
5356
if self.files_with_issues.values():
@@ -132,6 +135,27 @@ def issue_with_line(self, line):
132135
return b"\t" in line
133136

134137

138+
class MergeArtifactIssueTracker(IssueTracker):
139+
140+
def __init__(self):
141+
super().__init__()
142+
self.heading = "Merge artifact:"
143+
144+
def issue_with_line(self, filepath, line):
145+
# Detect leftover git conflict markers.
146+
if line.startswith(b'<<<<<<< ') or line.startswith(b'>>>>>>> '):
147+
return True
148+
if line.startswith(b'||||||| '): # from merge.conflictStyle=diff3
149+
return True
150+
if line.rstrip(b'\r\n') == b'=======' and \
151+
not filepath.endswith('.md'):
152+
return True
153+
return False
154+
155+
def check_file_line(self, filepath, line, line_number):
156+
if self.issue_with_line(filepath, line):
157+
self.record_issue(filepath, line_number)
158+
135159
class TodoIssueTracker(IssueTracker):
136160

137161
def __init__(self):
@@ -167,6 +191,7 @@ def __init__(self, log_file):
167191
LineEndingIssueTracker(),
168192
TrailingWhitespaceIssueTracker(),
169193
TabIssueTracker(),
194+
MergeArtifactIssueTracker(),
170195
TodoIssueTracker(),
171196
]
172197

0 commit comments

Comments
 (0)