Exclude .md files from version control conflict detection.
Turns out top-level headers basically look exactly like a merge conflict marker. R=jlklein@chromium.org BUG=495338 Review URL: https://codereview.chromium.org/1153013005 Cr-Commit-Position: refs/heads/master@{#332313}
This commit is contained in:
@ -841,6 +841,10 @@ def _CheckForVersionControlConflictsInFile(input_api, f):
|
||||
pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
|
||||
errors = []
|
||||
for line_num, line in f.ChangedContents():
|
||||
if f.LocalPath().endswith('.md'):
|
||||
# First-level headers in markdown look a lot like version control
|
||||
# conflict markers. http://daringfireball.net/projects/markdown/basics
|
||||
continue
|
||||
if pattern.match(line):
|
||||
errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line))
|
||||
return errors
|
||||
|
@ -270,6 +270,16 @@ class VersionControlConflictsTest(unittest.TestCase):
|
||||
self.assertTrue('3' in errors[1])
|
||||
self.assertTrue('5' in errors[2])
|
||||
|
||||
def testIgnoresReadmes(self):
|
||||
lines = ['A First Level Header',
|
||||
'====================',
|
||||
'',
|
||||
'A Second Level Header',
|
||||
'---------------------']
|
||||
errors = PRESUBMIT._CheckForVersionControlConflictsInFile(
|
||||
MockInputApi(), MockFile('some/polymer/README.md', lines))
|
||||
self.assertEqual(0, len(errors))
|
||||
|
||||
class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase):
|
||||
def testTypicalCorrectlyMatchedChange(self):
|
||||
diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
|
||||
|
Reference in New Issue
Block a user