Read a project's goals and audience from the file its config names, in place of README.md
CI / tests (pull_request) Successful in 2m17s

This commit is contained in:
2026-11-13 00:06:11 +01:00
parent b439cd82e1
commit eb61043c12
37 changed files with 243 additions and 147 deletions
+9 -2
View File
@@ -47,11 +47,18 @@ def main(argv: list[str]) -> int:
return 0
def located() -> ProjectConfig | Failure:
found = git("rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir")
def located(directory: str | None = None) -> ProjectConfig | Failure:
"""The config of the checkout that holds directory, else the current directory."""
found = git("rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir", cwd=directory)
if isinstance(found, Failure):
return found
if len(lines := found.splitlines()) != 2:
return Failure(f"git rev-parse printed {found!r}, not a checkout's top folder and git directory on two lines")
# The common dir is the main checkout's .git, whichever worktree runs this.
return load(pathlib.Path(lines[0]), pathlib.Path(lines[1]).parent, pathlib.Path.home())
def goals_file(directory: str) -> pathlib.Path | Failure:
"""The file holding the premises, `## Goals` and `## Audience`, of the project whose checkout holds directory."""
config = located(directory)
return config if isinstance(config, Failure) else config.paths["goals-and-audience"]