feat: convenience command to apply all formatter patches (#14994)
* feat: convenience to apply all formatter patches run-clang-format.py can create multiple patchfiles. This change prints a command that can be pasted into a shell to apply all of them together. * feat: put all generated style diffs in one file This way it will be easier to `git apply` fixes to multiple fixed files at once.
This commit is contained in:
parent
05f4860889
commit
e9a5b19223
1 changed files with 13 additions and 6 deletions
|
@ -281,6 +281,9 @@ def main():
|
||||||
njobs = multiprocessing.cpu_count() + 1
|
njobs = multiprocessing.cpu_count() + 1
|
||||||
njobs = min(len(files), njobs)
|
njobs = min(len(files), njobs)
|
||||||
|
|
||||||
|
patch_file = tempfile.NamedTemporaryFile(delete=False,
|
||||||
|
prefix='electron-format-')
|
||||||
|
|
||||||
if njobs == 1:
|
if njobs == 1:
|
||||||
# execute directly instead of in a pool,
|
# execute directly instead of in a pool,
|
||||||
# less overhead, simpler stacktraces
|
# less overhead, simpler stacktraces
|
||||||
|
@ -315,14 +318,18 @@ def main():
|
||||||
continue
|
continue
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print_diff(outs, use_color=colored_stdout)
|
print_diff(outs, use_color=colored_stdout)
|
||||||
with tempfile.NamedTemporaryFile(delete=False) as patch_file:
|
for line in outs:
|
||||||
for line in outs:
|
patch_file.write(line)
|
||||||
patch_file.write(line)
|
patch_file.write('\n')
|
||||||
patch_file.write('\n')
|
|
||||||
print("\nTo apply this patch, run:\n$ git apply {}\n"
|
|
||||||
.format(patch_file.name))
|
|
||||||
if retcode == ExitStatus.SUCCESS:
|
if retcode == ExitStatus.SUCCESS:
|
||||||
retcode = ExitStatus.DIFF
|
retcode = ExitStatus.DIFF
|
||||||
|
|
||||||
|
if patch_file.tell() == 0:
|
||||||
|
os.unlink(patch_file.name)
|
||||||
|
else:
|
||||||
|
print("\nTo patch these files, run:\n$ git apply {}\n"
|
||||||
|
.format(patch_file.name))
|
||||||
|
|
||||||
return retcode
|
return retcode
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue