Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s
CI / tests (pull_request) Successful in 6m34s
This commit is contained in:
@@ -1,27 +1,31 @@
|
||||
"""The chunk's review folder, where each reviewer writes its report: skills/larv-review/SKILL.md → "Reports"."""
|
||||
from collections.abc import Mapping
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from failure import Failure
|
||||
from review_rules.round_titles import Findings, reported
|
||||
from loop_state.paths import STATE_FOLDER
|
||||
from loop_state.paths import state_folder
|
||||
|
||||
# Why here: docs/decisions.md → `review: each reviewer under agents/ writes its full report into the chunk's review folder`.
|
||||
REPORTS = f"{STATE_FOLDER}/larv-review"
|
||||
def reports_folder(home: pathlib.Path, env: Mapping[str, str]) -> pathlib.Path:
|
||||
"""The folder that holds every chunk's review folder."""
|
||||
return state_folder(env, home) / "larv-review"
|
||||
|
||||
|
||||
def review_folder(home: str, worktree: str) -> str:
|
||||
"""The review folder of the chunk whose worktree is at worktree: its path relative to home, or to / outside it, under REPORTS."""
|
||||
def review_folder(home: str, env: Mapping[str, str], worktree: str) -> str:
|
||||
"""The review folder of the chunk whose worktree is at worktree: its path relative to home, or to / outside it, under the reports folder."""
|
||||
inside = worktree.startswith(home.rstrip("/") + "/")
|
||||
return os.path.join(home, REPORTS, os.path.relpath(worktree, home) if inside else worktree.lstrip("/"))
|
||||
return os.path.join(reports_folder(pathlib.Path(home), env), os.path.relpath(worktree, home) if inside else worktree.lstrip("/"))
|
||||
|
||||
|
||||
def made_review_folder(worktree: str, home: pathlib.Path) -> pathlib.Path | Failure:
|
||||
"""Makes the review folder of the chunk whose worktree is at worktree, leaving REPORTS readable by the user alone, and returns its path."""
|
||||
folder = pathlib.Path(review_folder(str(home), worktree))
|
||||
def made_review_folder(worktree: str, home: pathlib.Path, env: Mapping[str, str]) -> pathlib.Path | Failure:
|
||||
"""Makes the review folder of the chunk whose worktree is at worktree, leaving the reports folder readable by the user alone, and returns its path."""
|
||||
folder = pathlib.Path(review_folder(str(home), env, worktree))
|
||||
reports = reports_folder(home, env)
|
||||
try:
|
||||
(home / REPORTS).mkdir(parents=True, exist_ok=True)
|
||||
(home / REPORTS).chmod(0o700)
|
||||
reports.mkdir(parents=True, exist_ok=True)
|
||||
reports.chmod(0o700)
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as failure:
|
||||
return Failure(f"could not make the review folder {folder}: {failure}")
|
||||
|
||||
@@ -12,11 +12,11 @@ from review_rules.review_folder import findings_in, review_folder, standing_repo
|
||||
|
||||
class ReviewFolder(unittest.TestCase):
|
||||
def test_keys_a_worktree_under_home_by_its_path_relative_to_home(self):
|
||||
self.assertEqual(review_folder("/h", "/h/code/proj-item-3"), "/h/.local/state/larv-review/code/proj-item-3")
|
||||
self.assertEqual(review_folder("/h", {}, "/h/code/proj-item-3"), "/h/.local/state/build-release/larv-review/code/proj-item-3")
|
||||
|
||||
def test_keys_a_worktree_outside_home_by_its_path_relative_to_the_root(self):
|
||||
self.assertEqual(review_folder("/h", "/srv/proj-item-3"), "/h/.local/state/larv-review/srv/proj-item-3")
|
||||
self.assertEqual(review_folder("/h", "/hx/proj"), "/h/.local/state/larv-review/hx/proj", "a sibling of home that shares its prefix is outside it")
|
||||
self.assertEqual(review_folder("/h", {}, "/srv/proj-item-3"), "/h/.local/state/build-release/larv-review/srv/proj-item-3")
|
||||
self.assertEqual(review_folder("/h", {}, "/hx/proj"), "/h/.local/state/build-release/larv-review/hx/proj", "a sibling of home that shares its prefix is outside it")
|
||||
|
||||
|
||||
class RoundReport(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user