diff options
| author | Simon Glass <[email protected]> | 2025-05-07 18:02:47 +0200 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2025-05-27 10:07:42 +0100 |
| commit | 60b8709b980a30a9ae2e4a702cb2ac5e117d2a92 (patch) | |
| tree | 4d7ee5094f4e4224eb131942bc2b7172042bfb26 /tools/patman/checkpatch.py | |
| parent | 4f7bd6cae8fa3697d8b90a15b83c47087933f61b (diff) | |
patman: Allow setting the current directory when sending
Plumb a current-working-directory (cwd) through from send all the way to
the command gitutil libraries. This will allow better testing of this
functionality, since we can use a test directory.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'tools/patman/checkpatch.py')
| -rw-r--r-- | tools/patman/checkpatch.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 2975881705c..5df06b1095a 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -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,8 @@ 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) return check_patch_parse(output, verbose) @@ -240,7 +243,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 +251,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): |
