Skip to content

Commit a02bfb3

Browse files
committed
switch to full path match in exclude config
1 parent 2b282d0 commit a02bfb3

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: [3.7, 3.8, 3.9]
18+
python-version: [3.13]
1919
steps:
2020
- uses: actions/checkout@v2
2121
with:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
author="Ilya Radostev",
2222
author_email="[email protected]",
2323
include_package_data=True,
24-
python_requires=">=3.7",
24+
python_requires=">=3.13",
2525
install_requires=REQUIREMENTS,
2626
entry_points={"console_scripts": [f"{__NAME__} = {__NAME__}.cli:run"]},
2727
)

trufflehog3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from trufflehog3 import helper
99

1010
__NAME__ = "trufflehog3"
11-
__VERSION__ = "3.0.10"
11+
__VERSION__ = "3.13.0"
1212

1313
HERE = Path(__file__).parent
1414
STATIC_DIR = HERE / "static"

trufflehog3/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def _match(
204204

205205
for exc in exclude:
206206
if exc.paths:
207-
path_matched = source._match(issue.path, exc.paths, recursive=True)
207+
path_matched = source._match(issue.path, exc.paths)
208208
else:
209209
path_matched = True
210210

trufflehog3/source.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _diffiter(
167167
if pdiff.startswith("Binary files"): # pragma: no cover
168168
continue
169169

170-
pattern = _match(fpath, exclude_set, recursive=True)
170+
pattern = _match(fpath, exclude_set)
171171
if pattern:
172172
log.debug(f"skipping diff '{fpath}': '{pattern}'")
173173
continue
@@ -218,13 +218,9 @@ def _get_branches(
218218
return [repo.branches[branch] if branch else repo.active_branch]
219219

220220

221-
def _match(
222-
path: str, patterns: Iterable[str] = None, recursive: bool = False
223-
) -> Optional[str]:
221+
def _match(path: str, patterns: Iterable[str] = None) -> Optional[str]:
224222
"""Match path against given glob patterns and return matched pattern if any.
225223
226-
If `recursive` is set to True, check all parent directories as well.
227-
228224
Note
229225
----
230226
Return None if `patterns` is empty or not set.
@@ -241,18 +237,16 @@ def _match(
241237
'*.yml'
242238
>>> _match(".git/hooks/update.sample", [".git/*"]) is None
243239
True
244-
>>> _match(".git/hooks/update.sample", [".git/*"], recursive=True)
245-
'.git/*'
240+
>>> _match(".git/hooks/update.sample", [".git/**/*"])
241+
'.git/**/*'
246242
247243
"""
248244
if not patterns:
249245
return None
250246

251247
fpath = Path(path)
252-
paths = [fpath, *fpath.parents] if recursive else [fpath]
253-
for p in paths:
254-
for glob in patterns:
255-
if p.match(glob):
256-
return glob
248+
for glob in patterns:
249+
if fpath.full_match(glob):
250+
return glob
257251

258252
return None

0 commit comments

Comments
 (0)