diff options
author | Tom Rini <trini@konsulko.com> | 2025-05-27 07:43:04 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-05-27 07:43:04 -0600 |
commit | 6015a24a5a2647ab044333ed8e2462f90f855e36 (patch) | |
tree | 53fe80bee534a17f6c40e697cc112287a0b4b3c5 /tools/patman/checkpatch.py | |
parent | 39b815d02d7ce6af32bcf023d20243c404b75a84 (diff) | |
parent | ec2482a24ac3a1d0beadae80bcb28c8d89b4c1ab (diff) |
Merge tag 'dm-next-27may25' of git://git.denx.de/u-boot-dm into next
Sync up Python tools from my tree
- minor binman tweaks
- terminal improvements in u_boot_pylib
- patman move to asyncio
- patman support for new 'series' subcommand
Diffstat (limited to 'tools/patman/checkpatch.py')
-rw-r--r-- | tools/patman/checkpatch.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 2975881705c..f9204a907ef 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -22,7 +22,7 @@ RE_NOTE = re.compile(r'NOTE: (.*)') def find_check_patch(): - top_level = gitutil.get_top_level() + top_level = gitutil.get_top_level() or '' try_list = [ os.getcwd(), os.path.join(os.getcwd(), '..', '..'), @@ -187,7 +187,8 @@ def check_patch_parse(checkpatch_output, verbose=False): return result -def check_patch(fname, verbose=False, show_types=False, use_tree=False): +def check_patch(fname, verbose=False, show_types=False, use_tree=False, + cwd=None): """Run checkpatch.pl on a file and parse the results. Args: @@ -196,6 +197,7 @@ def check_patch(fname, verbose=False, show_types=False, use_tree=False): parsed show_types: Tell checkpatch to show the type (number) of each message use_tree (bool): If False we'll pass '--no-tree' to checkpatch. + cwd (str): Path to use for patch files (None to use current dir) Returns: namedtuple containing: @@ -217,7 +219,9 @@ def check_patch(fname, verbose=False, show_types=False, use_tree=False): args.append('--no-tree') if show_types: args.append('--show-types') - output = command.output(*args, fname, raise_on_error=False) + output = command.output( + *args, os.path.join(cwd or '', fname), raise_on_error=False, + capture_stderr=not use_tree) return check_patch_parse(output, verbose) @@ -240,7 +244,7 @@ def get_warning_msg(col, msg_type, fname, line, msg): line_str = '' if line is None else '%d' % line return '%s:%s: %s: %s\n' % (fname, line_str, msg_type, msg) -def check_patches(verbose, args, use_tree): +def check_patches(verbose, args, use_tree, cwd): '''Run the checkpatch.pl script on each patch''' error_count, warning_count, check_count = 0, 0, 0 col = terminal.Color() @@ -248,7 +252,8 @@ def check_patches(verbose, args, use_tree): with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor: futures = [] for fname in args: - f = executor.submit(check_patch, fname, verbose, use_tree=use_tree) + f = executor.submit(check_patch, fname, verbose, use_tree=use_tree, + cwd=cwd) futures.append(f) for fname, f in zip(args, futures): |