feat: ability to apply patch to clang-format errors (#13576)
* feat: ability to apply patch to clang-format errors * improve error message formatting * fix line length linting error
This commit is contained in:
parent
35b867ff7d
commit
ab7a90e82f
1 changed files with 9 additions and 2 deletions
|
@ -19,6 +19,7 @@ import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
@ -68,8 +69,8 @@ def make_diff(diff_file, original, reformatted):
|
||||||
difflib.unified_diff(
|
difflib.unified_diff(
|
||||||
original,
|
original,
|
||||||
reformatted,
|
reformatted,
|
||||||
fromfile='{}\t(original)'.format(diff_file),
|
fromfile='a/{}'.format(diff_file),
|
||||||
tofile='{}\t(reformatted)'.format(diff_file),
|
tofile='b/{}'.format(diff_file),
|
||||||
n=3))
|
n=3))
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,6 +313,12 @@ 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:
|
||||||
|
patch_file.write(line)
|
||||||
|
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
|
||||||
return retcode
|
return retcode
|
||||||
|
|
Loading…
Reference in a new issue