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

Side by Side Diff: git_cl.py

Issue 1917863009: Subprocess uses shell=True on Windows when launching GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: fix nits Created 4 years, 7 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 sys.exit(1) 88 sys.exit(1)
89 89
90 90
91 def GetNoGitPagerEnv(): 91 def GetNoGitPagerEnv():
92 env = os.environ.copy() 92 env = os.environ.copy()
93 # 'cat' is a magical git string that disables pagers on all platforms. 93 # 'cat' is a magical git string that disables pagers on all platforms.
94 env['GIT_PAGER'] = 'cat' 94 env['GIT_PAGER'] = 'cat'
95 return env 95 return env
96 96
97 97
98 def RunCommand(args, error_ok=False, error_message=None, **kwargs): 98 def RunCommand(args, error_ok=False, error_message=None, shell=False, **kwargs):
99 try: 99 try:
100 return subprocess2.check_output(args, shell=False, **kwargs) 100 return subprocess2.check_output(args, shell=shell, **kwargs)
101 except subprocess2.CalledProcessError as e: 101 except subprocess2.CalledProcessError as e:
102 logging.debug('Failed running %s', args) 102 logging.debug('Failed running %s', args)
103 if not error_ok: 103 if not error_ok:
104 DieWithError( 104 DieWithError(
105 'Command "%s" failed.\n%s' % ( 105 'Command "%s" failed.\n%s' % (
106 ' '.join(args), error_message or e.stdout or '')) 106 ' '.join(args), error_message or e.stdout or ''))
107 return e.stdout 107 return e.stdout
108 108
109 109
110 def RunGit(args, **kwargs): 110 def RunGit(args, **kwargs):
(...skipping 4630 matching lines...) Expand 10 before | Expand all | Expand 10 after
4741 print ('Warning: Unable to check Dart code formatting. Dart SDK not ' + 4741 print ('Warning: Unable to check Dart code formatting. Dart SDK not ' +
4742 'found in this checkout. Files in other languages are still ' + 4742 'found in this checkout. Files in other languages are still ' +
4743 'formatted.') 4743 'formatted.')
4744 4744
4745 # Format GN build files. Always run on full build files for canonical form. 4745 # Format GN build files. Always run on full build files for canonical form.
4746 if gn_diff_files: 4746 if gn_diff_files:
4747 cmd = ['gn', 'format'] 4747 cmd = ['gn', 'format']
4748 if not opts.dry_run and not opts.diff: 4748 if not opts.dry_run and not opts.diff:
4749 cmd.append('--in-place') 4749 cmd.append('--in-place')
4750 for gn_diff_file in gn_diff_files: 4750 for gn_diff_file in gn_diff_files:
4751 stdout = RunCommand(cmd + [gn_diff_file], cwd=top_dir) 4751 stdout = RunCommand(cmd + [gn_diff_file],
4752 shell=sys.platform == 'win32',
4753 cwd=top_dir)
4752 if opts.diff: 4754 if opts.diff:
4753 sys.stdout.write(stdout) 4755 sys.stdout.write(stdout)
4754 4756
4755 return return_value 4757 return return_value
4756 4758
4757 4759
4758 @subcommand.usage('<codereview url or issue id>') 4760 @subcommand.usage('<codereview url or issue id>')
4759 def CMDcheckout(parser, args): 4761 def CMDcheckout(parser, args):
4760 """Checks out a branch associated with a given Rietveld or Gerrit issue.""" 4762 """Checks out a branch associated with a given Rietveld or Gerrit issue."""
4761 _, args = parser.parse_args(args) 4763 _, args = parser.parse_args(args)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
4855 if __name__ == '__main__': 4857 if __name__ == '__main__':
4856 # These affect sys.stdout so do it outside of main() to simplify mocks in 4858 # These affect sys.stdout so do it outside of main() to simplify mocks in
4857 # unit testing. 4859 # unit testing.
4858 fix_encoding.fix_encoding() 4860 fix_encoding.fix_encoding()
4859 setup_color.init() 4861 setup_color.init()
4860 try: 4862 try:
4861 sys.exit(main(sys.argv[1:])) 4863 sys.exit(main(sys.argv[1:]))
4862 except KeyboardInterrupt: 4864 except KeyboardInterrupt:
4863 sys.stderr.write('interrupted\n') 4865 sys.stderr.write('interrupted\n')
4864 sys.exit(1) 4866 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