Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: git_cl.py

Issue 196943006: Pass through "--filter" arguments from "git cl lint" to cpplint.py (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 log_args = [args[0][:-1]] 1375 log_args = [args[0][:-1]]
1376 elif len(args) == 2: 1376 elif len(args) == 2:
1377 log_args = [args[0] + '..' + args[1]] 1377 log_args = [args[0] + '..' + args[1]]
1378 else: 1378 else:
1379 log_args = args[:] # Hope for the best! 1379 log_args = args[:] # Hope for the best!
1380 return RunGit(['log', '--pretty=format:%s\n\n%b'] + log_args) 1380 return RunGit(['log', '--pretty=format:%s\n\n%b'] + log_args)
1381 1381
1382 1382
1383 def CMDlint(parser, args): 1383 def CMDlint(parser, args):
1384 """Runs cpplint on the current changelist.""" 1384 """Runs cpplint on the current changelist."""
1385 _, args = parser.parse_args(args) 1385 parser.add_option('--filter', action='append', metavar='-x,+y',
1386 help='Comma-separated list of cpplint\'s category-filters')
1387 (options, args) = parser.parse_args(args)
1386 1388
1387 # Access to a protected member _XX of a client class 1389 # Access to a protected member _XX of a client class
1388 # pylint: disable=W0212 1390 # pylint: disable=W0212
1389 try: 1391 try:
1390 import cpplint 1392 import cpplint
1391 import cpplint_chromium 1393 import cpplint_chromium
1392 except ImportError: 1394 except ImportError:
1393 print "Your depot_tools is missing cpplint.py and/or cpplint_chromium.py." 1395 print "Your depot_tools is missing cpplint.py and/or cpplint_chromium.py."
1394 return 1 1396 return 1
1395 1397
1396 # Change the current working directory before calling lint so that it 1398 # Change the current working directory before calling lint so that it
1397 # shows the correct base. 1399 # shows the correct base.
1398 previous_cwd = os.getcwd() 1400 previous_cwd = os.getcwd()
1399 os.chdir(settings.GetRoot()) 1401 os.chdir(settings.GetRoot())
1400 try: 1402 try:
1401 cl = Changelist() 1403 cl = Changelist()
1402 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) 1404 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None)
1403 files = [f.LocalPath() for f in change.AffectedFiles()] 1405 files = [f.LocalPath() for f in change.AffectedFiles()]
1404 1406
1405 # Process cpplints arguments if any. 1407 # Process cpplints arguments if any.
1406 filenames = cpplint.ParseArguments(args + files) 1408 command = args + files
1409 if options.filter:
1410 command = ['--filter=' + ','.join(options.filter)] + command
1411 filenames = cpplint.ParseArguments(command)
1407 1412
1408 white_regex = re.compile(settings.GetLintRegex()) 1413 white_regex = re.compile(settings.GetLintRegex())
1409 black_regex = re.compile(settings.GetLintIgnoreRegex()) 1414 black_regex = re.compile(settings.GetLintIgnoreRegex())
1410 extra_check_functions = [cpplint_chromium.CheckPointerDeclarationWhitespace] 1415 extra_check_functions = [cpplint_chromium.CheckPointerDeclarationWhitespace]
1411 for filename in filenames: 1416 for filename in filenames:
1412 if white_regex.match(filename): 1417 if white_regex.match(filename):
1413 if black_regex.match(filename): 1418 if black_regex.match(filename):
1414 print "Ignoring file %s" % filename 1419 print "Ignoring file %s" % filename
1415 else: 1420 else:
1416 cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level, 1421 cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level,
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2531 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2527 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2532 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2528 2533
2529 2534
2530 if __name__ == '__main__': 2535 if __name__ == '__main__':
2531 # These affect sys.stdout so do it outside of main() to simplify mocks in 2536 # These affect sys.stdout so do it outside of main() to simplify mocks in
2532 # unit testing. 2537 # unit testing.
2533 fix_encoding.fix_encoding() 2538 fix_encoding.fix_encoding()
2534 colorama.init() 2539 colorama.init()
2535 sys.exit(main(sys.argv[1:])) 2540 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698