Make chunk-pr merge wait for the human approval a project's config requires
CI / tests (pull_request) Failing after 3m11s

This commit is contained in:
2026-11-14 00:43:54 +01:00
parent 89a85f88df
commit 6cdbcbc08b
11 changed files with 205 additions and 16 deletions
+12 -4
View File
@@ -26,6 +26,10 @@ a path that starts with / or ~/ and lies outside the checkout and the config's f
"~/.claude-projects/acme-billing.env". Where it is left out, the project has no credentials file, and
a tool that needs one fails naming the setting. It is printed with the others only where it is set.
`wait-for-approval` is the other optional setting, true or false: whether `chunk-pr merge` waits for a human's
approval of the pull request, as GitHub's branch protection asks for it, before it merges. Where it is left out it
is false. Asked for by name it prints true or false; it is listed with the others only where it is true.
Exit 1, naming each fault on stderr, where no config names the checkout, or its config leaves out a
setting, names an unknown one or misspells a path, and where `env-file` is asked for and not set.
No setting has a default.
@@ -33,7 +37,7 @@ No setting has a default.
import pathlib
import sys
from project_config.settings import CONFIG, ENV_FILE, load, ProjectConfig, SETTINGS
from project_config.settings import CONFIG, ENV_FILE, load, ProjectConfig, SETTINGS, WAIT_FOR_APPROVAL
from failure import Failure
from git_cli.git_repo import git, Git
@@ -42,18 +46,22 @@ def main(argv: list[str]) -> int:
if argv[:1] in (["-h"], ["--help"]):
print(__doc__.strip())
return 0
if len(argv) > 1 or (argv and argv[0] not in (*SETTINGS, ENV_FILE)):
print(f"usage: project-config [<setting>], where <setting> is one of {', '.join((*SETTINGS, ENV_FILE))}", file=sys.stderr)
if len(argv) > 1 or (argv and argv[0] not in (*SETTINGS, ENV_FILE, WAIT_FOR_APPROVAL)):
print(f"usage: project-config [<setting>], where <setting> is one of {', '.join((*SETTINGS, ENV_FILE, WAIT_FOR_APPROVAL))}", file=sys.stderr)
return 1
config = located(None, pathlib.Path.home())
if isinstance(config, Failure):
print(config.reason, file=sys.stderr)
return 1
if argv == [WAIT_FOR_APPROVAL]:
print("true" if config.wait_for_approval else "false")
return 0
paths = {**config.paths, **({ENV_FILE: config.env_file} if config.env_file else {})}
if argv and argv[0] not in paths:
print(f"{config.folder / CONFIG} sets no `{ENV_FILE}`", file=sys.stderr)
return 1
print(paths[argv[0]] if argv else "\n".join(f"{name}: {path}" for name, path in paths.items()))
listed = [f"{name}: {path}" for name, path in paths.items()] + ([f"{WAIT_FOR_APPROVAL}: true"] if config.wait_for_approval else [])
print(paths[argv[0]] if argv else "\n".join(listed))
return 0