Changeset View
Changeset View
Standalone View
Standalone View
utils_maintenance/clang_format_paths.py
| Context not available. | |||||
| return paths | return paths | ||||
| def source_files_from_git(paths): | def source_files_from_git(paths, changed_only): | ||||
| cmd = ("git", "ls-tree", "-r", "HEAD", *paths, "--name-only", "-z") | if changed_only: | ||||
| cmd = ("git", "diff", "-r", "HEAD", "--name-only", "-z",*paths) | |||||
Severin: Whitespace. | |||||
SeverinUnsubmitted Not Done Inline Actions,*paths is the whitespace culprit ;) Severin: `,*paths` is the whitespace culprit ;) | |||||
| else: | |||||
| cmd = ("git", "ls-tree", "-r", "HEAD", *paths, "--name-only", "-z") | |||||
| files = subprocess.check_output(cmd).split(b'\0') | files = subprocess.check_output(cmd).split(b'\0') | ||||
| return [f.decode('ascii') for f in files] | return [f.decode('ascii') for f in files] | ||||
| Context not available. | |||||
| "(default=False)", | "(default=False)", | ||||
| required=False, | required=False, | ||||
| ) | ) | ||||
| parser.add_argument( | |||||
| "--changed-only", | |||||
| dest="changed_only", | |||||
| default=False, | |||||
| action='store_true', | |||||
| help="Run only format changed files " | |||||
SeverinUnsubmitted Done Inline ActionsSounds a bit messed up? :) Severin: Sounds a bit messed up? :) | |||||
| "(default=False)", | |||||
| required=False, | |||||
| ) | |||||
| parser.add_argument( | parser.add_argument( | ||||
| "paths", | "paths", | ||||
| nargs=argparse.REMAINDER, | nargs=argparse.REMAINDER, | ||||
| Context not available. | |||||
| print(" ", p) | print(" ", p) | ||||
| files = [ | files = [ | ||||
| f for f in source_files_from_git(paths) | f for f in source_files_from_git(paths,args.changed_only) | ||||
SeverinUnsubmitted Done Inline ActionsWhitespace. Severin: Whitespace. | |||||
| if f.endswith(extensions) | if f.endswith(extensions) | ||||
| if f not in ignore_files | if f not in ignore_files | ||||
| ] | ] | ||||
| # Always operate on all cmake files (when expanding tabs and no paths given). | # Always operate on all cmake files (when expanding tabs and no paths given). | ||||
| files_retab = [ | files_retab = [ | ||||
| f for f in source_files_from_git((".",) if use_default_paths else paths) | f for f in source_files_from_git((".",) if use_default_paths else paths, args.changed_only) | ||||
Not Done Inline ActionsThis is getting a bit too complex for my taste now, so I would write this as: git_paths = (".",) if use_default_paths else paths
files_retab = [
f for f in source_files_from_git(git_paths, args.changed_only)
if f.endswith(extensions_only_retab)
if f not in ignore_files
]sybren: This is getting a bit too complex for my taste now, so I would write this as:
```
git_paths =… | |||||
| if f.endswith(extensions_only_retab) | if f.endswith(extensions_only_retab) | ||||
| if f not in ignore_files | if f not in ignore_files | ||||
| ] | ] | ||||
| Context not available. | |||||
Whitespace.