Answer stability round 1: 0 🔴, 2 🟡 (0 misread); inject home into the goals file lookup and rename readme in ranking
This commit is contained in:
@@ -39,7 +39,7 @@ def main(argv: list[str]) -> int:
|
||||
if len(argv) > 1 or (argv and argv[0] not in SETTINGS):
|
||||
print(f"usage: project-config [<setting>], where <setting> is one of {', '.join(SETTINGS)}", file=sys.stderr)
|
||||
return 1
|
||||
config = located()
|
||||
config = located(None, pathlib.Path.home())
|
||||
if isinstance(config, Failure):
|
||||
print(config.reason, file=sys.stderr)
|
||||
return 1
|
||||
@@ -47,18 +47,18 @@ def main(argv: list[str]) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def located(directory: str | None = None) -> ProjectConfig | Failure:
|
||||
"""The config of the checkout that holds directory, else the current directory."""
|
||||
def located(directory: str | None, home: pathlib.Path) -> ProjectConfig | Failure:
|
||||
"""The config under home 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())
|
||||
return load(pathlib.Path(lines[0]), pathlib.Path(lines[1]).parent, 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)
|
||||
def goals_file(directory: str, home: pathlib.Path) -> pathlib.Path | Failure:
|
||||
"""The file holding the premises, `## Goals` and `## Audience`, of the project whose checkout holds directory, as its config under home names it."""
|
||||
config = located(directory, home)
|
||||
return config if isinstance(config, Failure) else config.paths["goals-and-audience"]
|
||||
|
||||
Reference in New Issue
Block a user