mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 01:35:38 +00:00
check-files: detect merge artifacts
Detect Git merge artifacts. These are lines starting with "<<<<<<", "|||||||" or ">>>>>>>" followed by a space, or containing just "=======". For "=======", exempt Markdown files, because this can be used to underline a title, as a compromise between false negatives and false positives.
This commit is contained in:
parent
232fae37e3
commit
da6ccfca68
|
@ -135,6 +135,27 @@ class TabIssueTracker(IssueTracker):
|
|||
return b"\t" in line
|
||||
|
||||
|
||||
class MergeArtifactIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.heading = "Merge artifact:"
|
||||
|
||||
def issue_with_line(self, filepath, line):
|
||||
# Detect leftover git conflict markers.
|
||||
if line.startswith(b'<<<<<<< ') or line.startswith(b'>>>>>>> '):
|
||||
return True
|
||||
if line.startswith(b'||||||| '): # from merge.conflictStyle=diff3
|
||||
return True
|
||||
if line.rstrip(b'\r\n') == b'=======' and \
|
||||
not filepath.endswith('.md'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def check_file_line(self, filepath, line, line_number):
|
||||
if self.issue_with_line(filepath, line):
|
||||
self.record_issue(filepath, line_number)
|
||||
|
||||
class TodoIssueTracker(IssueTracker):
|
||||
|
||||
def __init__(self):
|
||||
|
@ -171,6 +192,7 @@ class IntegrityChecker(object):
|
|||
LineEndingIssueTracker(),
|
||||
TrailingWhitespaceIssueTracker(),
|
||||
TabIssueTracker(),
|
||||
MergeArtifactIssueTracker(),
|
||||
TodoIssueTracker(),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue