Skip to content

Commit

Permalink
Only use relative paths with function is_ignored()
Browse files Browse the repository at this point in the history
The is_ignored() function expects paths relative to the starting
path given when initializing the class. It raises a traceback
if given an absolute path.

Signed-off-by: Eric Brown <[email protected]>
  • Loading branch information
ericwb committed Jan 31, 2024
1 parent 2ef4388 commit 0162dbf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions precli/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,16 @@ def discover_files(targets: list[str], recursive: bool):
if recursive is True:
for root, _, files in gitignore_mgr.walk():
for file in files:
path = os.path.join(root, file)
if not preignore_mgr.is_ignored(path):
file_list.append(path)
if not preignore_mgr.is_ignored(file):
file_list.append(os.path.join(root, file))
else:
files = os.listdir(path=fname)
for file in files:
path = os.path.join(fname, file)
if not (
gitignore_mgr.is_ignored(path)
or preignore_mgr.is_ignored(path)
gitignore_mgr.is_ignored(file)
or preignore_mgr.is_ignored(file)
):
file_list.append(path)
file_list.append(os.path.join(fname, file))
else:
file_list.append(fname)
return file_list
Expand Down

0 comments on commit 0162dbf

Please sign in to comment.