Callers use Civilytics/docs-review/.gitea/workflows/review.yml@v1 with secrets: inherit. Stage 1 on every pull request; for drafter: claude, a 180-second wait and then the sandboxed drafter; closed pull requests close their docs PR; schedule and dispatch run the monthly pass. Tested live against Gitea 28.3 (drafter none, a misspelled drafter, claude, close). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ade847ba5b
commit
f39409e62c
11 files changed
+466
-26
No files matched your search
+30
-7
@@ -43,8 +43,16 @@ def run(args: list[str], cwd: Path, extra_env: Mapping[str, str] | None = None)
|
||||
|
||||
|
||||
def checkout_new(branch: str, rev: str, cwd: Path) -> None:
|
||||
"""Create or reset branch at rev and switch to it."""
|
||||
run(["checkout", "-q", "-B", branch, EOO, rev], cwd)
|
||||
"""Create or reset branch at rev and switch to it.
|
||||
|
||||
git before 2.43 reads a revision after --end-of-options in checkout as a pathspec
|
||||
("Cannot update paths and switch to branch"), and node:22 ships 2.39. So an
|
||||
option-like branch or rev is refused here instead, and the trailing -- keeps rev a
|
||||
revision."""
|
||||
for value in (branch, rev):
|
||||
if not value or value.startswith("-"):
|
||||
raise GitError(f"refusing to check out {value!r}")
|
||||
run(["checkout", "-q", "-B", branch, rev, "--"], cwd)
|
||||
|
||||
|
||||
def merge(rev: str, author: tuple[str, str], cwd: Path) -> None:
|
||||
@@ -54,6 +62,12 @@ def merge(rev: str, author: tuple[str, str], cwd: Path) -> None:
|
||||
"-c", "commit.gpgsign=false", "merge", "--no-edit", EOO, rev], cwd)
|
||||
|
||||
|
||||
def fetch(branch: str, cwd: Path) -> None:
|
||||
"""Fetch one branch from origin into FETCH_HEAD; the branch can never read as an
|
||||
option."""
|
||||
run(["fetch", "-q", "origin", EOO, branch], cwd)
|
||||
|
||||
|
||||
def merge_base(a: str, b: str, cwd: Path) -> str:
|
||||
return run(["merge-base", EOO, a, b], cwd).strip()
|
||||
|
||||
@@ -112,17 +126,26 @@ def commit(paths: list[str], message: str, author: tuple[str, str], cwd: Path) -
|
||||
)
|
||||
|
||||
|
||||
def push(branch: str, cwd: Path, token: str | None) -> None:
|
||||
def header_key(server: str | None) -> str:
|
||||
"""The config key for the auth header: scoped to the Gitea server when it is known,
|
||||
so the header is never sent to any other host."""
|
||||
if server:
|
||||
return f"http.{server.rstrip('/')}/.extraHeader"
|
||||
return "http.extraHeader"
|
||||
|
||||
|
||||
def push(branch: str, cwd: Path, token: str | None, server: str | None = None) -> None:
|
||||
"""Push branch to origin under an explicit refspec, never forced.
|
||||
|
||||
The token travels as an http.extraHeader set through GIT_CONFIG_* variables on this
|
||||
call only, so it never reaches argv or .git/config. A branch starting with + or -
|
||||
could force the push or read as an option, so it is refused."""
|
||||
The token travels as an extraHeader set through GIT_CONFIG_* variables on this call
|
||||
only, so it never reaches argv or .git/config; with server (GITHUB_SERVER_URL) the
|
||||
header is scoped to that URL. A branch starting with + or - could force the push or
|
||||
read as an option, so it is refused."""
|
||||
if not branch or branch.startswith(("+", "-")):
|
||||
raise GitError(f"refusing to push branch {branch!r}")
|
||||
extra = None
|
||||
if token:
|
||||
extra = {"GIT_CONFIG_COUNT": "1", "GIT_CONFIG_KEY_0": "http.extraHeader",
|
||||
extra = {"GIT_CONFIG_COUNT": "1", "GIT_CONFIG_KEY_0": header_key(server),
|
||||
"GIT_CONFIG_VALUE_0": f"Authorization: token {token}"}
|
||||
ref = f"refs/heads/{branch}"
|
||||
run(["push", "origin", f"{ref}:{ref}"], cwd, extra_env=extra)
|
||||
Reference in new issue
Block a user