rhiza 0.6.1__py3-none-any.whl → 0.7.0__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.
@@ -320,13 +320,52 @@ def materialize(target: Path, branch: str, target_branch: str | None, force: boo
320
320
  )
321
321
  logger.info(f"Workflow files affected: {len(workflow_files)}")
322
322
 
323
+ # -----------------------
324
+ # Clean up orphaned files
325
+ # -----------------------
326
+ # Read the old .rhiza.history file to find files that are no longer
327
+ # part of the current materialization and should be deleted
328
+ history_file = target / ".rhiza.history"
329
+ previously_tracked_files: set[Path] = set()
330
+
331
+ if history_file.exists():
332
+ logger.debug("Reading existing .rhiza.history file")
333
+ with history_file.open("r", encoding="utf-8") as f:
334
+ for line in f:
335
+ line = line.strip()
336
+ # Skip comments and empty lines
337
+ if line and not line.startswith("#"):
338
+ previously_tracked_files.add(Path(line))
339
+
340
+ logger.debug(f"Found {len(previously_tracked_files)} file(s) in previous .rhiza.history")
341
+
342
+ # Convert materialized_files list to a set for comparison
343
+ currently_materialized_files = set(materialized_files)
344
+
345
+ # Find orphaned files (in old history but not in new materialization)
346
+ orphaned_files = previously_tracked_files - currently_materialized_files
347
+
348
+ if orphaned_files:
349
+ logger.info(f"Found {len(orphaned_files)} orphaned file(s) no longer maintained by template")
350
+ for file_path in sorted(orphaned_files):
351
+ full_path = target / file_path
352
+ if full_path.exists():
353
+ try:
354
+ full_path.unlink()
355
+ logger.success(f"[DEL] {file_path}")
356
+ except Exception as e:
357
+ logger.warning(f"Failed to delete {file_path}: {e}")
358
+ else:
359
+ logger.debug(f"Skipping {file_path} (already deleted)")
360
+ else:
361
+ logger.debug("No orphaned files to clean up")
362
+
323
363
  # -----------------------
324
364
  # Write .rhiza.history
325
365
  # -----------------------
326
366
  # This file tracks which files were materialized by Rhiza
327
367
  # Useful for understanding which files came from the template
328
368
  logger.debug("Writing .rhiza.history file")
329
- history_file = target / ".rhiza.history"
330
369
  with history_file.open("w", encoding="utf-8") as f:
331
370
  f.write("# Rhiza Template History\n")
332
371
  f.write("# This file lists all files managed by the Rhiza template.\n")
@@ -338,7 +377,7 @@ def materialize(target: Path, branch: str, target_branch: str | None, force: boo
338
377
  for file_path in sorted(materialized_files):
339
378
  f.write(f"{file_path}\n")
340
379
 
341
- logger.info(f"Created {history_file.relative_to(target)} with {len(materialized_files)} file(s)")
380
+ logger.info(f"Updated {history_file.relative_to(target)} with {len(materialized_files)} file(s)")
342
381
 
343
382
  logger.success("Rhiza templates materialized successfully")
344
383
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rhiza
3
- Version: 0.6.1
3
+ Version: 0.7.0
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
@@ -4,11 +4,11 @@ rhiza/cli.py,sha256=faCIOKDzEDRvL4doLZhiIAyHUUGESGrwWLtjLjimCUY,5111
4
4
  rhiza/models.py,sha256=fW9lofkkid-bghk2bXEgBdGbZ4scSqG726fMrVfKX_M,3454
5
5
  rhiza/commands/__init__.py,sha256=Z5CeMh7ylX27H6dvwqRbEKzYo5pwQq-5TyTxABUSaQg,1848
6
6
  rhiza/commands/init.py,sha256=Hrox_o8hnyWMkx4SuE0rd4jqGIBEl_V_wh7BAiW9IFU,5726
7
- rhiza/commands/materialize.py,sha256=Sxuvh9GLDRkcl6LVTjvWo5bkYzQ5GLwlhOwLo2jNptI,14387
7
+ rhiza/commands/materialize.py,sha256=jmXH9Fb3lkktxgdWtZ2cQk0wyURleWzHvQN6n_DNZ7U,16049
8
8
  rhiza/commands/validate.py,sha256=cxStfXbY_ifsc_yRDCg0TOnv8jG05hxE9rteta-X9hQ,8093
9
9
  rhiza/commands/welcome.py,sha256=w3BziR042o6oYincd3EqDsFzF6qqInU7iYhWjF3yJqY,2382
10
- rhiza-0.6.1.dist-info/METADATA,sha256=tx98rTT3r_muUBFnlZ_L8KxDbzhQqC_sAocefsoGLf8,22742
11
- rhiza-0.6.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
12
- rhiza-0.6.1.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
13
- rhiza-0.6.1.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
14
- rhiza-0.6.1.dist-info/RECORD,,
10
+ rhiza-0.7.0.dist-info/METADATA,sha256=00UAERh_SGq5WoD8xZsbl83SdNZBO8QjBCP0Al-qQKM,22742
11
+ rhiza-0.7.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
12
+ rhiza-0.7.0.dist-info/entry_points.txt,sha256=NAwZUpbXvfKv50a_Qq-PxMHl3lcjAyZO63IBeuUNgfY,45
13
+ rhiza-0.7.0.dist-info/licenses/LICENSE,sha256=4m5X7LhqX-6D0Ks79Ys8CLpmza8cxDG34g4S9XSNAGY,1077
14
+ rhiza-0.7.0.dist-info/RECORD,,
File without changes