rhiza 0.8.6__py3-none-any.whl → 0.8.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rhiza/commands/materialize.py +21 -0
- rhiza/models.py +25 -2
- {rhiza-0.8.6.dist-info → rhiza-0.8.8.dist-info}/METADATA +1 -1
- {rhiza-0.8.6.dist-info → rhiza-0.8.8.dist-info}/RECORD +7 -7
- {rhiza-0.8.6.dist-info → rhiza-0.8.8.dist-info}/WHEEL +0 -0
- {rhiza-0.8.6.dist-info → rhiza-0.8.8.dist-info}/entry_points.txt +0 -0
- {rhiza-0.8.6.dist-info → rhiza-0.8.8.dist-info}/licenses/LICENSE +0 -0
rhiza/commands/materialize.py
CHANGED
|
@@ -251,6 +251,19 @@ def _copy_files_to_target(
|
|
|
251
251
|
# Create set of excluded files
|
|
252
252
|
logger.debug("Expanding excluded paths to individual files")
|
|
253
253
|
excluded_files = {f.resolve() for f in __expand_paths(tmp_dir, excluded_paths)}
|
|
254
|
+
|
|
255
|
+
# Always exclude .rhiza/template.yml to prevent overwriting local configuration
|
|
256
|
+
# Also exclude .rhiza/history to prevent overwriting local history with template history
|
|
257
|
+
rhiza_dir = tmp_dir / ".rhiza"
|
|
258
|
+
template_config = (rhiza_dir / "template.yml").resolve()
|
|
259
|
+
upstream_history = (rhiza_dir / "history").resolve()
|
|
260
|
+
|
|
261
|
+
if template_config.is_file():
|
|
262
|
+
excluded_files.add(template_config)
|
|
263
|
+
|
|
264
|
+
if upstream_history.is_file():
|
|
265
|
+
excluded_files.add(upstream_history)
|
|
266
|
+
|
|
254
267
|
if excluded_files:
|
|
255
268
|
logger.info(f"Excluding {len(excluded_files)} file(s) based on exclude patterns")
|
|
256
269
|
|
|
@@ -336,9 +349,17 @@ def _clean_orphaned_files(target: Path, materialized_files: list[Path]) -> None:
|
|
|
336
349
|
currently_materialized_files = set(materialized_files)
|
|
337
350
|
orphaned_files = previously_tracked_files - currently_materialized_files
|
|
338
351
|
|
|
352
|
+
# Protected files that should never be deleted automatically
|
|
353
|
+
# even if they are orphaned (e.g. user chose to stop tracking them)
|
|
354
|
+
protected_files = {Path(".rhiza/template.yml")}
|
|
355
|
+
|
|
339
356
|
if orphaned_files:
|
|
340
357
|
logger.info(f"Found {len(orphaned_files)} orphaned file(s) no longer maintained by template")
|
|
341
358
|
for file_path in sorted(orphaned_files):
|
|
359
|
+
if file_path in protected_files:
|
|
360
|
+
logger.info(f"Skipping protected file: {file_path}")
|
|
361
|
+
continue
|
|
362
|
+
|
|
342
363
|
full_path = target / file_path
|
|
343
364
|
if full_path.exists():
|
|
344
365
|
try:
|
rhiza/models.py
CHANGED
|
@@ -11,6 +11,29 @@ from pathlib import Path
|
|
|
11
11
|
import yaml
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
def _normalize_to_list(value: str | list[str] | None) -> list[str]:
|
|
15
|
+
"""Convert a value to a list of strings.
|
|
16
|
+
|
|
17
|
+
Handles the case where YAML multi-line strings (using |) are parsed as
|
|
18
|
+
a single string instead of a list. Splits the string by newlines and
|
|
19
|
+
strips whitespace from each item.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
value: A string, list of strings, or None.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
A list of strings. Empty list if value is None or empty.
|
|
26
|
+
"""
|
|
27
|
+
if value is None:
|
|
28
|
+
return []
|
|
29
|
+
if isinstance(value, list):
|
|
30
|
+
return value
|
|
31
|
+
if isinstance(value, str):
|
|
32
|
+
# Split by newlines and filter out empty strings
|
|
33
|
+
return [item.strip() for item in value.strip().split("\n") if item.strip()]
|
|
34
|
+
return []
|
|
35
|
+
|
|
36
|
+
|
|
14
37
|
@dataclass
|
|
15
38
|
class RhizaTemplate:
|
|
16
39
|
"""Represents the structure of .github/rhiza/template.yml.
|
|
@@ -57,8 +80,8 @@ class RhizaTemplate:
|
|
|
57
80
|
template_repository=config.get("template-repository"),
|
|
58
81
|
template_branch=config.get("template-branch"),
|
|
59
82
|
template_host=config.get("template-host", "github"),
|
|
60
|
-
include=config.get("include"
|
|
61
|
-
exclude=config.get("exclude"
|
|
83
|
+
include=_normalize_to_list(config.get("include")),
|
|
84
|
+
exclude=_normalize_to_list(config.get("exclude")),
|
|
62
85
|
)
|
|
63
86
|
|
|
64
87
|
def to_yaml(self, file_path: Path) -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rhiza
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.8
|
|
4
4
|
Summary: Reusable configuration templates for modern Python projects
|
|
5
5
|
Project-URL: Homepage, https://github.com/jebel-quant/rhiza-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/jebel-quant/rhiza-cli
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
rhiza/__init__.py,sha256=iW3niLBjwRKxcMhIV_1eb78putjUTo2tbZsadofluJk,1939
|
|
2
2
|
rhiza/__main__.py,sha256=Q02upTGaJceknkDABdCwq5_vdMdGY8Cg3ej6WZIHs_s,829
|
|
3
3
|
rhiza/cli.py,sha256=xIsyfKjSFjVLjCS7o2om5o_YLZx9lIhsI0MTMI5Zs2k,8594
|
|
4
|
-
rhiza/models.py,sha256=
|
|
4
|
+
rhiza/models.py,sha256=o_iD8P7d7RAHH6J91tSPmD6lY-2HUsCaIl8auWqm2NM,4216
|
|
5
5
|
rhiza/subprocess_utils.py,sha256=Pr5TysIKP76hc64fmqhTd6msMGn5DU43hOSR_v_GFb8,745
|
|
6
6
|
rhiza/_templates/basic/__init__.py.jinja2,sha256=gs8qN4LAKcdFd6iO9gZVLuVetODmZP_TGuEjWrbinC0,27
|
|
7
7
|
rhiza/_templates/basic/main.py.jinja2,sha256=uTCahxf9Bftao1IghHue4cSZ9YzBYmBEXeIhEmK9UXQ,362
|
|
8
8
|
rhiza/_templates/basic/pyproject.toml.jinja2,sha256=Mizpnnd_kFQd-pCWOxG-KWhvg4_ZhZaQppTt2pz0WOc,695
|
|
9
9
|
rhiza/commands/__init__.py,sha256=Z5CeMh7ylX27H6dvwqRbEKzYo5pwQq-5TyTxABUSaQg,1848
|
|
10
10
|
rhiza/commands/init.py,sha256=73MLPLp-M8U4fP8J5RXghS6FsZjx2PpeeBbKRZvLQ7U,8882
|
|
11
|
-
rhiza/commands/materialize.py,sha256=
|
|
11
|
+
rhiza/commands/materialize.py,sha256=U6MouBNrg_GjYIPD0vBb3nacFBKGP4l8RD-HH0u-mYk,18538
|
|
12
12
|
rhiza/commands/migrate.py,sha256=pT8izKuX2eXCAkmNfcy4AU5HTB1DoOZoBXcZo2AOpXs,7520
|
|
13
13
|
rhiza/commands/uninstall.py,sha256=MJbQtmdTgbzMvQz0gGLW3aw6S1dSV8nLv0SqWSDpyPk,7469
|
|
14
14
|
rhiza/commands/validate.py,sha256=pg7SpgavvrjDyuZIphJ_GOMnXkwdVs9WtL2caa1XjcM,10811
|
|
15
15
|
rhiza/commands/welcome.py,sha256=w3BziR042o6oYincd3EqDsFzF6qqInU7iYhWjF3yJqY,2382
|
|
16
|
-
rhiza-0.8.
|
|
17
|
-
rhiza-0.8.
|
|
18
|
-
rhiza-0.8.
|
|
19
|
-
rhiza-0.8.
|
|
20
|
-
rhiza-0.8.
|
|
16
|
+
rhiza-0.8.8.dist-info/METADATA,sha256=PGkXXTlS2XGjxAm5ODJmDvrRerXnEmG1ZoUcJvYhiyo,25395
|
|
17
|
+
rhiza-0.8.8.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
18
|
+
rhiza-0.8.8.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
|
|
19
|
+
rhiza-0.8.8.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
|
|
20
|
+
rhiza-0.8.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|