Commit af43f40e authored by Nodir Turakulov's avatar Nodir Turakulov Committed by Commit Bot

Fix git cl format --python --full

Make `git cl format --python -full --dry-run` return non-zero exit code if
files are not well formatted.

Make `git cl format --python -full --diff` print diff, rather than new file
contents.

Change-Id: I666d360051563898d3508d776817bf9a61433cb0
Reviewed-on: https://chromium-review.googlesource.com/1081340Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Nodir Turakulov <nodir@chromium.org>
parent cf4aced3
......@@ -5851,12 +5851,15 @@ def CMDformat(parser, args):
if opts.full:
if python_diff_files:
cmd = [yapf_tool]
if not opts.dry_run and not opts.diff:
cmd.append('-i')
stdout = RunCommand(cmd + python_diff_files, cwd=top_dir)
if opts.diff:
sys.stdout.write(stdout)
if opts.dry_run or opts.diff:
cmd = [yapf_tool, '--diff'] + python_diff_files
stdout = RunCommand(cmd, error_ok=True, cwd=top_dir)
if opts.diff:
sys.stdout.write(stdout)
elif len(stdout) > 0:
return_value = 2
else:
RunCommand([yapf_tool, '-i'] + python_diff_files, cwd=top_dir)
else:
# TODO(sbc): yapf --lines mode still has some issues.
# https://github.com/google/yapf/issues/154
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment