Home | History | Annotate | Download | only in ios
      1 # Copyright (c) 2012 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 import os
      6 
      7 """Chromium presubmit script for src/tools/ios.
      8 
      9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
     10 for more details on the presubmit API built into gcl.
     11 """
     12 
     13 WHITELIST_FILE = 'build/ios/grit_whitelist.txt'
     14 
     15 def _CheckWhitelistSorted(input_api, output_api):
     16   for path in input_api.LocalPaths():
     17     if WHITELIST_FILE == path:
     18       lines = open(os.path.join('../..', WHITELIST_FILE)).readlines()
     19       sorted = all(lines[i] <= lines[i + 1] for i in xrange(len(lines) - 1))
     20       if not sorted:
     21         return [output_api.PresubmitError(
     22             'The file ' + WHITELIST_FILE + ' must be sorted.')]
     23   return []
     24 
     25 def _CommonChecks(input_api, output_api):
     26   """Checks common to both upload and commit."""
     27   results = []
     28   results.extend(_CheckWhitelistSorted(input_api, output_api))
     29   return results
     30 
     31 def CheckChangeOnUpload(input_api, output_api):
     32   results = []
     33   results.extend(_CommonChecks(input_api, output_api))
     34   return results
     35 
     36 def CheckChangeOnCommit(input_api, output_api):
     37   results = []
     38   results.extend(_CommonChecks(input_api, output_api))
     39   return results
     40