Skip to content

Commit af30d4e

Browse files
authored
fix: Hatch hook exclude patterns (#342)
* fix(hatch hook): exclude patterns as paths * bump minor versions for hatch and pdm hooks, and the CLI
1 parent 8bda95d commit af30d4e

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

components/polylith/parsing/core.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from pathlib import Path
44
from typing import List, Set, Union
55

6+
from polylith import repo
7+
68
default_patterns = {
79
"*.pyc",
810
"__pycache__",
@@ -27,7 +29,9 @@ def any_match(root: Path, patterns: set, name: str, current: Path) -> bool:
2729
return any(is_match(root, pattern, name, current) for pattern in patterns)
2830

2931

30-
def ignore_paths(root: Path, patterns: Set[str]):
32+
def ignore_paths(patterns: Set[str]):
33+
root = repo.get_workspace_root(Path.cwd())
34+
3135
def fn(current_path: str, names: List[str]):
3236
current = Path(current_path).resolve()
3337

@@ -36,22 +40,9 @@ def fn(current_path: str, names: List[str]):
3640
return fn
3741

3842

39-
def calculate_root(current_path: str) -> Path:
40-
relative = Path(current_path)
41-
42-
parts = [p for p in relative.parts if p != ".."]
43-
relative_path = "/".join(parts)
44-
45-
root = relative.resolve().as_posix().replace(relative_path, "")
46-
47-
return Path(root)
48-
49-
5043
def copy_tree(source: str, destination: str, patterns: Set[str]) -> Path:
51-
root = calculate_root(source)
52-
5344
is_paths = any("/" in p for p in patterns)
54-
fn = ignore_paths(root, patterns) if is_paths else shutil.ignore_patterns(*patterns)
45+
fn = ignore_paths(patterns) if is_paths else shutil.ignore_patterns(*patterns)
5546

5647
res = shutil.copytree(source, destination, ignore=fn, dirs_exist_ok=True)
5748

projects/hatch_polylith_bricks/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "hatch-polylith-bricks"
3-
version = "1.5.0"
3+
version = "1.5.1"
44
description = "Hatch build hook plugin for Polylith"
55
authors = ['David Vujic']
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"

projects/pdm_polylith_bricks/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pdm-polylith-bricks"
3-
version = "1.3.0"
3+
version = "1.3.1"
44
description = "a PDM build hook for Polylith"
55
authors = ["David Vujic"]
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"

projects/pdm_polylith_workspace/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pdm-polylith-workspace"
3-
version = "1.3.0"
3+
version = "1.3.1"
44
description = "a PDM build hook for a Polylith workspace"
55
homepage = "https://davidvujic.github.io/python-polylith-docs/"
66
repository = "https://github.com/davidvujic/python-polylith"

projects/polylith_cli/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "polylith-cli"
3-
version = "1.30.0"
3+
version = "1.30.1"
44
description = "Python tooling support for the Polylith Architecture"
55
authors = ['David Vujic']
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"

0 commit comments

Comments
 (0)