From 1de4cb45167d656b0def9fa18132b494ecaa9f1e Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 3 Nov 2026 10:12:40 +0100 Subject: [PATCH] fix: cleanup keeps the generated files of today --- scripts/cleanup_disk.py | 6 ++++-- tests/test_autorun.py | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/cleanup_disk.py b/scripts/cleanup_disk.py index 5c393739b..1e13da6b4 100644 --- a/scripts/cleanup_disk.py +++ b/scripts/cleanup_disk.py @@ -8,7 +8,8 @@ sessions create theirs. A worktree elsewhere on disk and the automation worktree (.cache/autorun/worktree) are never candidates. One is removed only when no process runs in or holds a file of it, it is older than --hours, and nothing tracked is modified in it except generated artifacts (database.json, -install/*.json, exports/*.json, README.md, mkdocs.yml). Branches are always +install/*.json, exports/*.json, README.md, CONTRIBUTING.md, +website/src/data/*.json). Branches are always kept, so committed work stays reachable. A worktree with real uncommitted code is listed, never removed. @@ -39,7 +40,8 @@ from dataclasses import dataclass from pathlib import Path GENERATED = re.compile( - r"^(database\.json|install/.*\.json|exports/.*\.json|README\.md|mkdocs\.yml)$" + r"^(database\.json|install/.*\.json|exports/.*\.json|README\.md|CONTRIBUTING\.md" + r"|website/src/data/[^/]+\.json)$" ) KEPT_TMP = ("acquire",) AUTOMATION_WORKTREE = Path(".cache") / "autorun" / "worktree" diff --git a/tests/test_autorun.py b/tests/test_autorun.py index fbdbf4912..354f64a7a 100644 --- a/tests/test_autorun.py +++ b/tests/test_autorun.py @@ -687,6 +687,15 @@ class Cleanup(Origin): def _decisions(self, busy=()) -> dict[str, cd.Decision]: return {d.path.name: d for d in cd.plan(self.repo, busy, self.HOURS, time.time())} + def test_generated_files_are_the_ones_a_run_rewrites(self): + """mkdocs.yml stayed in the list after the site moved to Starlight, + while CONTRIBUTING.md and website/src/data/*.json were left out.""" + for path in ("README.md", "CONTRIBUTING.md", "database.json", "install/retroarch.json", + "exports/batocera.json", "website/src/data/source-paths.json"): + self.assertTrue(cd.GENERATED.match(path), path) + for path in ("mkdocs.yml", "website/src/data/x/y.json", "scripts/verify.py"): + self.assertFalse(cd.GENERATED.match(path), path) + def test_worktree_and_tmp_rules(self): old_clean = self._worktree("old-clean", 100) old_code = self._worktree("old-code", 100)