Home | History | Annotate | Download | only in app_list
      1 # Copyright 2014 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 """Presubmit script for app_list.
      6 
      7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
      8 for more details about the presubmit API built into depot_tools.
      9 """
     10 
     11 CC_SOURCE_FILES=(r'^cc/.*\.(cc|h)$',)
     12 
     13 def CheckChangeLintsClean(input_api, output_api):
     14   input_api.cpplint._cpplint_state.ResetErrorCounts()  # reset global state
     15   source_filter = lambda x: input_api.FilterSourceFile(
     16     x, white_list=CC_SOURCE_FILES, black_list=None)
     17   files = [f.AbsoluteLocalPath() for f in
     18            input_api.AffectedSourceFiles(source_filter)]
     19   level = 1  # strict, but just warn
     20 
     21   for file_name in files:
     22     input_api.cpplint.ProcessFile(file_name, level)
     23 
     24   if not input_api.cpplint._cpplint_state.error_count:
     25     return []
     26 
     27   return [output_api.PresubmitPromptWarning(
     28     'Changelist failed cpplint.py check.')]
     29 
     30 def CheckChangeOnUpload(input_api, output_api):
     31   results = []
     32   results += CheckChangeLintsClean(input_api, output_api)
     33   results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
     34   return results
     35