Fix clang-format & autopep8 do extra work when nothing to operate on
When passing `.py` paths to the format command, clang-format paths would be empty and operate on all paths. Resolve by detecting cases when there is nothing to format. Ref: !126055
This commit is contained in:
committed by
Campbell Barton
parent
7971e6a9c2
commit
76eed5c65a
@@ -276,8 +276,12 @@ def main() -> int:
|
||||
print("Using \"{:s}\", ({:s})...".format(autopep8_source, version_str_from_tuple(version)))
|
||||
|
||||
use_default_paths = not (bool(args.paths) or bool(args.changed_only))
|
||||
|
||||
paths = compute_paths(args.paths, use_default_paths)
|
||||
# Check if user-defined paths exclude all Python sources.
|
||||
if args.paths and not paths:
|
||||
print("Skip autopep8: no target to format")
|
||||
return 0
|
||||
|
||||
print("Operating on:" + (" ({:d} changed paths)".format(len(paths)) if args.changed_only else ""))
|
||||
for p in paths:
|
||||
print(" ", p)
|
||||
|
||||
@@ -234,8 +234,12 @@ def main() -> int:
|
||||
args = argparse_create().parse_args()
|
||||
|
||||
use_default_paths = not (bool(args.paths) or bool(args.changed_only))
|
||||
|
||||
paths = compute_paths(args.paths, use_default_paths)
|
||||
# Check if user-defined paths exclude all clang-format sources.
|
||||
if args.paths and not paths:
|
||||
print("Skip clang-format: no target to format")
|
||||
return 0
|
||||
|
||||
print("Operating on:" + (" ({:d} changed paths)".format(len(paths)) if args.changed_only else ""))
|
||||
for p in paths:
|
||||
print(" ", p)
|
||||
|
||||
Reference in New Issue
Block a user