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:
@@ -88,6 +88,7 @@ clone, or the default branch cannot be read; or, after the rest of the report, w
|
||||
build-release's archive cannot be read.
|
||||
"""
|
||||
import functools
|
||||
from collections.abc import Mapping
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
@@ -119,7 +120,7 @@ UNMERGED = [
|
||||
]
|
||||
|
||||
|
||||
def main(argv: list[str], home: pathlib.Path) -> int:
|
||||
def main(argv: list[str], home: pathlib.Path, env: Mapping[str, str]) -> int:
|
||||
if argv[:1] in (["-h"], ["--help"]):
|
||||
print(__doc__.strip())
|
||||
return 0
|
||||
@@ -133,10 +134,10 @@ def main(argv: list[str], home: pathlib.Path) -> int:
|
||||
default, note = found
|
||||
if note:
|
||||
print(f"score-outcomes: {note}", file=sys.stderr)
|
||||
results = read_results(default, home)
|
||||
results = read_results(default, home, env)
|
||||
if isinstance(results, Failure):
|
||||
return failed(results)
|
||||
anchored = read_anchors(home)
|
||||
anchored = read_anchors(home, env)
|
||||
reversal = read_reversals(home)
|
||||
print(report_text(results, anchored, dict(zip(GIVEN, map(int, argv))) if argv else None, reversal))
|
||||
unread = [found for found in (anchored, reversal) if isinstance(found, Failure)]
|
||||
@@ -167,9 +168,9 @@ def failed(failure: Failure) -> int:
|
||||
return 1
|
||||
|
||||
|
||||
def read_anchors(home: pathlib.Path) -> Anchors | Failure:
|
||||
def read_anchors(home: pathlib.Path, env: Mapping[str, str]) -> Anchors | Failure:
|
||||
"""The project's anchors as they stand in the store its config names, so a branch that edits them shows its edit; none where it keeps none."""
|
||||
config = located(None, home)
|
||||
config = located(None, home, env)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
text = store(config, "score-anchors").read()
|
||||
@@ -184,17 +185,17 @@ def read_reversals(home: pathlib.Path) -> list[str] | Failure:
|
||||
return reversal_lines(project_archive(str(pathlib.Path(common.strip()).parent), home, os.environ))
|
||||
|
||||
|
||||
def read_results(default: str, home: pathlib.Path) -> list[Result] | Failure:
|
||||
def read_results(default: str, home: pathlib.Path, env: Mapping[str, str]) -> list[Result] | Failure:
|
||||
"""What each chunk on the default branch's first-parent line measured."""
|
||||
if partial := full_history():
|
||||
return partial
|
||||
if why := unsupported(None, home):
|
||||
if why := unsupported(None, home, env):
|
||||
return Failure(f"this project is not supported yet: {why}")
|
||||
root = top()
|
||||
if isinstance(root, Failure):
|
||||
return root
|
||||
run = functools.partial(git, cwd=root)
|
||||
templates = title_templates(None, home)
|
||||
templates = title_templates(None, home, env)
|
||||
if isinstance(templates, Failure):
|
||||
return templates
|
||||
chunks = branch_chunks(default, run, templates)
|
||||
|
||||
@@ -316,7 +316,7 @@ class ScoreOutcomesTool(unittest.TestCase):
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=cwd or self.checkout, env=self.env, text=True)
|
||||
|
||||
def test_says_it_does_not_support_a_plan_outside_the_checkout_and_reads_the_anchors_where_the_config_puts_them(self):
|
||||
config = pathlib.Path(self.env["HOME"], ".claude-projects", "proj", "config.toml")
|
||||
config = pathlib.Path(self.env["HOME"], ".config/build-release", "proj", "config.toml")
|
||||
config.write_text(config.read_text().replace('"checkout:docs/score-anchors.md"', '"folder:score-anchors.md"'))
|
||||
(config.parent / "score-anchors.md").write_text("| Level | Items |\n|---|---|\n| L 9 | 1 |\n")
|
||||
ran = self.run_tool()
|
||||
@@ -438,7 +438,7 @@ class ScoreOutcomesTool(unittest.TestCase):
|
||||
self.assertNotIn("by rebase", ran.stdout)
|
||||
|
||||
def test_reads_a_drop_title_through_the_configs_title_template(self):
|
||||
config = pathlib.Path(self.env["HOME"], ".claude-projects", "proj", "config.toml")
|
||||
config = pathlib.Path(self.env["HOME"], ".config/build-release", "proj", "config.toml")
|
||||
config.write_text(config.read_text() + 'commit-title = "PAY-{id} - {summary}"\n')
|
||||
self.commit("PAY-5 - Drop item 5: moot", {"b.py": "1\n", "todo.md": todo(FIRST)})
|
||||
self.git("switch", "-q", "-c", "chunk")
|
||||
@@ -570,12 +570,12 @@ class Reversals(unittest.TestCase):
|
||||
class ReadAnchors(unittest.TestCase):
|
||||
def test_fails_on_anchors_it_cannot_read_rather_than_scoring_without_them(self):
|
||||
checkout = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||
home = configured(self, checkout).parents[1]
|
||||
home = configured(self, checkout).parents[2]
|
||||
self.enterContext(contextlib.chdir(checkout))
|
||||
anchors = checkout.resolve() / "docs" / "score-anchors.md"
|
||||
anchors.parent.mkdir()
|
||||
anchors.write_bytes(b"\xff")
|
||||
self.assertEqual(read_anchors(home), Failure(f"cannot read {anchors}: not UTF-8 on line 1"))
|
||||
self.assertEqual(read_anchors(home, {}), Failure(f"cannot read {anchors}: not UTF-8 on line 1"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user