Skip to content

Commit

Permalink
🐛 Fix trailing single asterisk matching subdirs
Browse files Browse the repository at this point in the history
This patch aims to prevent path patterns ending with `/*` from being
greedy and interpreted the same as `/**`. After applying it, that
trailing asterisk only matches one file or directory but not nested
ones.
  • Loading branch information
webknjaz committed Aug 11, 2023
1 parent b2d780d commit 5e2d1e5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion coverage/files.py
Expand Up @@ -316,7 +316,7 @@ def sep(s: str) -> str:
(r"\*\*+[^/]+", None), # Can't have **x
(r"\*\*/\*\*", None), # Can't have **/**
(r"^\*+/", r"(.*[/\\\\])?"), # ^*/ matches any prefix-slash, or nothing.
(r"/\*+$", r"[/\\\\].*"), # /*$ matches any slash-suffix.
(r"/\*\*+$", r"[/\\\\].*"), # /**$ matches any slash-suffix.
(r"\*\*/", r"(.*[/\\\\])?"), # **/ matches any subdirs, including none
(r"/", r"[/\\\\]"), # / matches either slash or backslash
(r"\*", r"[^/\\\\]*"), # * matches any number of non slash-likes
Expand Down
2 changes: 1 addition & 1 deletion tests/test_report.py
Expand Up @@ -107,7 +107,7 @@ def test_report_omitting(self) -> None:
self.make_mycode()
cov = coverage.Coverage()
self.start_import_stop(cov, "mycode")
report = self.get_report(cov, omit=[f"{TESTS_DIR}/*", "*/site-packages/*"])
report = self.get_report(cov, omit=[f"{TESTS_DIR}/**", "*/site-packages/**"])

# Name Stmts Miss Cover
# -------------------------------
Expand Down

0 comments on commit 5e2d1e5

Please sign in to comment.