Skip to content

Commit

Permalink
Changed errant sys.argv to args parameter passed in.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akfreed committed May 18, 2022
1 parent 336fdd7 commit 46b5aad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, command: str, look_behind: str, args: List[str]):
self.look_behind = look_behind
self.command = command
# Will be [] if not run using pre-commit or if there are no committed files
self.files = self.get_added_files()
self.files = self.get_added_files(args)
self.edit_in_place = False

self.stdout = b""
Expand All @@ -35,9 +35,9 @@ def check_installed(self):
) # noqa: E501
self.raise_error(problem, details)

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

Expand Down

0 comments on commit 46b5aad

Please sign in to comment.