@@ -43,11 +43,14 @@ def check_file_for_issue(self, filepath):
43
43
for i , line in enumerate (iter (f .readline , b"" )):
44
44
self .check_file_line (filepath , line , i + 1 )
45
45
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
+
46
51
def check_file_line (self , filepath , line , line_number ):
47
52
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 )
51
54
52
55
def output_file_issues (self , logger ):
53
56
if self .files_with_issues .values ():
@@ -132,6 +135,27 @@ def issue_with_line(self, line):
132
135
return b"\t " in line
133
136
134
137
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
+
135
159
class TodoIssueTracker (IssueTracker ):
136
160
137
161
def __init__ (self ):
@@ -167,6 +191,7 @@ def __init__(self, log_file):
167
191
LineEndingIssueTracker (),
168
192
TrailingWhitespaceIssueTracker (),
169
193
TabIssueTracker (),
194
+ MergeArtifactIssueTracker (),
170
195
TodoIssueTracker (),
171
196
]
172
197
0 commit comments