diff --git a/presubmit_support.py b/presubmit_support.py index e1fcd3d08..a292bd78d 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -186,15 +186,16 @@ class InputApi(object): # File extensions that are considered source files from a style guide # perspective. Don't modify this list from a presubmit script! + # + # Files without an extension aren't included in the list. If you want to + # filter them as source files, add r"(^|.*?[\\\/])[^.]+$" to the white list. + # Note that ALL CAPS files are black listed in DEFAULT_BLACK_LIST below. DEFAULT_WHITE_LIST = ( # C++ and friends r".+\.c$", r".+\.cc$", r".+\.cpp$", r".+\.h$", r".+\.m$", r".+\.mm$", r".+\.inl$", r".+\.asm$", r".+\.hxx$", r".+\.hpp$", r".+\.s$", r".+\.S$", # Scripts r".+\.js$", r".+\.py$", r".+\.sh$", r".+\.rb$", r".+\.pl$", r".+\.pm$", - # No extension at all, note that ALL CAPS files are black listed in - # DEFAULT_BLACK_LIST below. - r"(^|.*?[\\\/])[^.]+$", # Other r".+\.java$", r".+\.mk$", r".+\.am$", ) diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 9ef2675b0..7f87be418 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -945,7 +945,6 @@ class InputApiUnittest(PresubmitTestsBase): ], [ # Expected. - 'a/experimental', 'a/experimental.cc', 'a/experimental.S', ], @@ -960,7 +959,6 @@ class InputApiUnittest(PresubmitTestsBase): ], [ # Expected. - 'a/third_party', 'a/third_party.cc', ], ), @@ -970,11 +968,13 @@ class InputApiUnittest(PresubmitTestsBase): f('a/LOL_FILE/b'), f('b.c/LOL_FILE'), f('a/PRESUBMIT.py'), + f('a/FOO.json'), + f('a/FOO.java'), ], [ # Expected. - 'a/LOL_FILE/b', 'a/PRESUBMIT.py', + 'a/FOO.java', ], ), ( @@ -995,7 +995,7 @@ class InputApiUnittest(PresubmitTestsBase): False, None, False) self.mox.ReplayAll() - self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 22) + self.assertEqual(len(input_api.DEFAULT_WHITE_LIST), 21) self.assertEqual(len(input_api.DEFAULT_BLACK_LIST), 9) for item in files: results = filter(input_api.FilterSourceFile, item[0])