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

Unified Diff: git_cl.py

Issue 2220123002: Update "git cl format" for GN changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 1726fd4ad22ace1825cde8febcf261c029b5ab0c..014c3dc82b2c003b4085377d0efff70e5c55e0a6 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -4983,15 +4983,24 @@ def CMDformat(parser, args):
# Format GN build files. Always run on full build files for canonical form.
if gn_diff_files:
- cmd = ['gn', 'format']
- if not opts.dry_run and not opts.diff:
- cmd.append('--in-place')
+ cmd = ['gn', 'format' ]
+ if opts.dry_run or opts.diff:
+ cmd.append('--dry-run')
for gn_diff_file in gn_diff_files:
- stdout = RunCommand(cmd + [gn_diff_file],
- shell=sys.platform == 'win32',
- cwd=top_dir)
- if opts.diff:
- sys.stdout.write(stdout)
+ gn_ret = subprocess2.call(cmd + [gn_diff_file],
+ shell=sys.platform == 'win32',
+ cwd=top_dir)
+ if opts.dry_run and gn_ret == 2:
+ return_value = 2 # Not formatted.
+ elif opts.diff and gn_ret == 2:
+ # TODO this should compute and print the actual diff.
+ print("This change has GN build file diff for " + gn_diff_file)
+ elif gn_ret != 0:
+ # For non-dry run cases (and non-2 return values for dry-run), a
+ # nonzero error code indicates a failure, probably because the file
+ # doesn't parse.
+ DieWithError("gn format failed on " + gn_diff_file +
+ "\nTry running 'gn format' on this file manually.")
return return_value
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698