Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set #801

Merged
lilleman merged 16 commits from item-484 into main 2026-12-03 22:24:17 +01:00
6 changed files with 14 additions and 9 deletions
Showing only changes of commit 9ae3e85cba - Show all commits
+2 -2
View File
@@ -167,8 +167,8 @@ class StartChunks(unittest.TestCase):
self.assertEqual(self.starts(fake), [("new-session", "item-1", [str(self.LAUNCHER), "--chunk", "item-1", "ship it"]), ("new-window", "item-3", [str(self.LAUNCHER), "--chunk", "item-3", "ship it"])])
first = next(call for call in fake.tmux_calls if call[0] == "new-session")
self.assertEqual((first[first.index("-s") + 1], first[first.index("-c") + 1]), (self.session, str(self.root)))
# Only build-release's own variables are handed on, since a window gets the tmux server's environment.
self.assertEqual([word for word in first if "=" in word], ["BUILD_RELEASE_WORKER_MODEL=m"])
# Only build-release's own variables and the two XDG ones are handed on, since a window gets the tmux server's environment.
self.assertEqual([word for word in first if "=" in word], ["BUILD_RELEASE_WORKER_MODEL=m", "XDG_CONFIG_HOME=", "XDG_STATE_HOME="])
self.assertEqual(fake.tmux_calls[0], ["list-windows", "-t", f"={self.session}", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"])
# The session names the checkout whose chunks it runs.
self.assertIn(["set-option", "-t", f"={self.session}:", "@loop-root", str(self.root)], fake.tmux_calls)
+1 -1
View File
@@ -836,7 +836,7 @@ class Windows(unittest.TestCase):
["-V"],
["list-windows", "-t", "=loop-proj", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"],
["list-windows", "-a", "-F", "#{session_name}\t#{window_name}\t#{pane_dead}\t#{window_id}\t#{@chunk-root}"],
["new-session", "-d", "-s", "loop-proj", "-n", "item-4", "-c", str(checkout.root), "-e", "BUILD_RELEASE_JUDGE_MODEL=judge-model", "-e", "BUILD_RELEASE_WORKER_MODEL=worker-model", "-P", "-F", "#{window_id}", "--", str(checkout.script), "--chunk", "item-4", "ship it"],
["new-session", "-d", "-s", "loop-proj", "-n", "item-4", "-c", str(checkout.root), "-e", "BUILD_RELEASE_JUDGE_MODEL=judge-model", "-e", "BUILD_RELEASE_WORKER_MODEL=worker-model", "-e", "XDG_CONFIG_HOME=", "-e", "XDG_STATE_HOME=", "-P", "-F", "#{window_id}", "--", str(checkout.script), "--chunk", "item-4", "ship it"],
["set-option", "-t", "=loop-proj:", "@loop-root", str(checkout.root)],
["set-option", "-w", "-t", "@7", "@chunk-root", str(checkout.root)],
["set-option", "-w", "-t", "@7", "remain-on-exit", "failed"],
+4 -3
View File
@@ -20,10 +20,11 @@ CHUNK_FLAG = "--chunk"
OWN = "BUILD_RELEASE_"
# A window gets the tmux server's environment, not the starting terminal's. Without the two XDG variables, a window would lock and write in other folders than the entry point that started it.
# A window gets the tmux server's environment, not the starting terminal's. With another XDG value than its starter's, a window would lock and write in other folders. So each is handed even where the starter lacks it, as empty: an empty value moves no folder.
def handed(env: typing.Mapping[str, str]) -> dict[str, str]:
"""The variables of env that an entry point hands each window it starts: those both entry points read, and the two that move the config folder and the state folder."""
return {name: value for name, value in env.items() if name.startswith(OWN) or name in (XDG_CONFIG_HOME, XDG_STATE_HOME)}
"""The variables an entry point hands each window it starts: those of env that both entry points read, and the two that move the config folder and the state folder."""
own = {name: value for name, value in env.items() if name.startswith(OWN)}
return {**own, XDG_CONFIG_HOME: env.get(XDG_CONFIG_HOME, ""), XDG_STATE_HOME: env.get(XDG_STATE_HOME, "")}
@contextlib.contextmanager
+2 -2
View File
@@ -14,8 +14,8 @@ class Handed(unittest.TestCase):
env = {"BUILD_RELEASE_JUDGE_MODEL": "judge", "XDG_CONFIG_HOME": "/configs", "XDG_STATE_HOME": "/state", "XDG_DATA_HOME": "/data", "PATH": "/bin"}
self.assertEqual(handed(env), {"BUILD_RELEASE_JUDGE_MODEL": "judge", "XDG_CONFIG_HOME": "/configs", "XDG_STATE_HOME": "/state"})
def test_hands_no_variable_the_starter_lacks(self) -> None:
self.assertEqual(handed({"PATH": "/bin"}), {})
def test_hands_an_xdg_variable_the_starter_lacks_as_empty_so_the_tmux_servers_value_moves_no_folder(self) -> None:
self.assertEqual(handed({"PATH": "/bin", "XDG_STATE_HOME": "/state"}), {"XDG_CONFIG_HOME": "", "XDG_STATE_HOME": "/state"})
class Starting(unittest.TestCase):
+1 -1
View File
@@ -146,7 +146,7 @@ class TheCommand(DoEpicTest):
self.assertIn("started ABC-21 in the tmux session epic-ABC-12\n", out)
self.assertIn("ABC-20 waits: it is a human's task\n", out)
started = [args for args in fake.tmux_calls if args[0] == "new-session"]
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-epic", "--chunk", "ABC-21", "ABC-12"]])
self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "XDG_CONFIG_HOME=", "-e", "XDG_STATE_HOME=", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-epic", "--chunk", "ABC-21", "ABC-12"]])
# The session is no checkout's, so nothing marks it as one's.
self.assertNotIn(tmux.OWNER, [args[3] for args in fake.tmux_calls if args[0] == "set-option"])
+4
View File
@@ -1268,6 +1268,10 @@ class Hook(unittest.TestCase):
self.assertIn("Blocked by rule commit-title: title the commit as the project's config asks, `PAY-{id} - {summary}`", self.round_commit("Tidy").stderr)
self.assertIn("Blocked by rule round-title-counts", self.round_commit("PAY-7 - Answer stability round 1: 0 🔴, 0 🟡 (0 misread); x").stderr)
self.assertEqual(self.round_commit("PAY-7 - Answer stability round 1: 0 🔴, 1 🟡 (0 misread); x").returncode, 0)
pathlib.Path(self.repo, "todo.md").write_text("# todo\n")
plan = self.round_commit("PAY-7 - Tidy").stderr
self.assertIn("Blocked by rule todo-rank-check", plan)
self.assertNotIn("no config names the checkout", plan)
def test_a_commit_on_a_branch_that_doesnt_fit_the_configs_branch_template_takes_a_bare_title(self):
config = self.configured() / "config.toml"