Skip to content

Commit 46b5aad

Browse files
committed
Changed errant sys.argv to args parameter passed in.
In some use cases, the args param given to the Command constructor was a filtered version of sys.argv. Command.get_added_files() was reading directly from sys.argv, circumventing this filtering.
1 parent 336fdd7 commit 46b5aad

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hooks/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, command: str, look_behind: str, args: List[str]):
1717
self.look_behind = look_behind
1818
self.command = command
1919
# Will be [] if not run using pre-commit or if there are no committed files
20-
self.files = self.get_added_files()
20+
self.files = self.get_added_files(args)
2121
self.edit_in_place = False
2222

2323
self.stdout = b""
@@ -35,9 +35,9 @@ def check_installed(self):
3535
) # noqa: E501
3636
self.raise_error(problem, details)
3737

38-
def get_added_files(self):
38+
def get_added_files(self, args):
3939
"""Find added files using git."""
40-
added_files = sys.argv[1:] # 1: don't include the hook file
40+
added_files = args[1:] # 1: don't include the hook file
4141
# cfg files are used by uncrustify and won't be source files
4242
added_files = [f for f in added_files if os.path.exists(f) and not f.endswith(".cfg")]
4343

0 commit comments

Comments
 (0)