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

Side by Side Diff: git_cl.py

Issue 1880013002: Check for clang-format only if its files are present (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 8 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 and Gerrit.""" 8 """A git-command for integrating reviews on Rietveld and Gerrit."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 4422 matching lines...) Expand 10 before | Expand all | Expand 10 after
4433 diff_files = [x for x in diff_files if os.path.isfile(x)] 4433 diff_files = [x for x in diff_files if os.path.isfile(x)]
4434 4434
4435 clang_diff_files = [x for x in diff_files if MatchingFileType(x, CLANG_EXTS)] 4435 clang_diff_files = [x for x in diff_files if MatchingFileType(x, CLANG_EXTS)]
4436 python_diff_files = [x for x in diff_files if MatchingFileType(x, ['.py'])] 4436 python_diff_files = [x for x in diff_files if MatchingFileType(x, ['.py'])]
4437 dart_diff_files = [x for x in diff_files if MatchingFileType(x, ['.dart'])] 4437 dart_diff_files = [x for x in diff_files if MatchingFileType(x, ['.dart'])]
4438 gn_diff_files = [x for x in diff_files if MatchingFileType(x, GN_EXTS)] 4438 gn_diff_files = [x for x in diff_files if MatchingFileType(x, GN_EXTS)]
4439 4439
4440 top_dir = os.path.normpath( 4440 top_dir = os.path.normpath(
4441 RunGit(["rev-parse", "--show-toplevel"]).rstrip('\n')) 4441 RunGit(["rev-parse", "--show-toplevel"]).rstrip('\n'))
4442 4442
4443 # Locate the clang-format binary in the checkout
4444 try:
4445 clang_format_tool = clang_format.FindClangFormatToolInChromiumTree()
4446 except clang_format.NotFoundError, e:
4447 DieWithError(e)
4448
4449 # Set to 2 to signal to CheckPatchFormatted() that this patch isn't 4443 # Set to 2 to signal to CheckPatchFormatted() that this patch isn't
4450 # formatted. This is used to block during the presubmit. 4444 # formatted. This is used to block during the presubmit.
4451 return_value = 0 4445 return_value = 0
4452 4446
4453 if clang_diff_files: 4447 if clang_diff_files:
4448 # Locate the clang-format binary in the checkout
4449 try:
4450 clang_format_tool = clang_format.FindClangFormatToolInChromiumTree()
4451 except clang_format.NotFoundError, e:
4452 DieWithError(e)
4453
4454 if opts.full: 4454 if opts.full:
4455 cmd = [clang_format_tool] 4455 cmd = [clang_format_tool]
4456 if not opts.dry_run and not opts.diff: 4456 if not opts.dry_run and not opts.diff:
4457 cmd.append('-i') 4457 cmd.append('-i')
4458 stdout = RunCommand(cmd + clang_diff_files, cwd=top_dir) 4458 stdout = RunCommand(cmd + clang_diff_files, cwd=top_dir)
4459 if opts.diff: 4459 if opts.diff:
4460 sys.stdout.write(stdout) 4460 sys.stdout.write(stdout)
4461 else: 4461 else:
4462 env = os.environ.copy() 4462 env = os.environ.copy()
4463 env['PATH'] = str(os.path.dirname(clang_format_tool)) 4463 env['PATH'] = str(os.path.dirname(clang_format_tool))
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
4628 if __name__ == '__main__': 4628 if __name__ == '__main__':
4629 # These affect sys.stdout so do it outside of main() to simplify mocks in 4629 # These affect sys.stdout so do it outside of main() to simplify mocks in
4630 # unit testing. 4630 # unit testing.
4631 fix_encoding.fix_encoding() 4631 fix_encoding.fix_encoding()
4632 setup_color.init() 4632 setup_color.init()
4633 try: 4633 try:
4634 sys.exit(main(sys.argv[1:])) 4634 sys.exit(main(sys.argv[1:]))
4635 except KeyboardInterrupt: 4635 except KeyboardInterrupt:
4636 sys.stderr.write('interrupted\n') 4636 sys.stderr.write('interrupted\n')
4637 sys.exit(1) 4637 sys.exit(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