feat(slice4): bot.commit_entry_files + open_entry_pr multi-file primitives (§22.4a)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+38
-1
@@ -27,7 +27,7 @@ import json
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
|
||||
from . import db, entry as entry_mod, notify
|
||||
from . import db, entry as entry_mod, metadata as metadata_mod, notify
|
||||
from .gitea import Gitea, GiteaError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -404,6 +404,43 @@ class Bot:
|
||||
pr_number=pr_number,
|
||||
)
|
||||
|
||||
# ----- Entry sidecar writes (§22.4a SLICE-4) -----
|
||||
|
||||
async def commit_entry_files(
|
||||
self, actor: Actor, *, org: str, repo: str,
|
||||
files: list[dict], message: str, branch: str = "main",
|
||||
) -> dict:
|
||||
"""Commit a set of entry file ops (sidecar + body-only `.md`, from
|
||||
`metadata.write_entry_files`) in one commit. Used by the direct-commit
|
||||
metadata paths and, on a branch, by `open_entry_pr`."""
|
||||
return await self._gitea.change_files(
|
||||
org, repo, files=files,
|
||||
message=_stamp_single(message, actor), branch=branch,
|
||||
author_name=actor.display_name,
|
||||
author_email=actor.email or f"{actor.gitea_login}@users.noreply",
|
||||
)
|
||||
|
||||
async def open_entry_pr(
|
||||
self, actor: Actor, *, org: str, repo: str, slug: str,
|
||||
files: list[dict], pr_title: str, pr_description: str,
|
||||
branch_prefix: str = "metadata",
|
||||
) -> dict:
|
||||
"""Create a branch, commit entry file ops there, and open a PR — the
|
||||
sidecar-aware successor to `open_metadata_pr`'s single-file write."""
|
||||
import secrets
|
||||
|
||||
branch = f"{branch_prefix}-{slug}-{secrets.token_hex(3)}"
|
||||
await self._gitea.create_branch(org, repo, branch, from_branch="main")
|
||||
await self.commit_entry_files(
|
||||
actor, org=org, repo=repo, files=files,
|
||||
message=pr_title, branch=branch)
|
||||
_subject, pr_body = _stamp("", pr_description, actor)
|
||||
pr = await self._gitea.create_pull(
|
||||
org, repo, title=pr_title, body=pr_body, head=branch, base="main")
|
||||
_log(actor, "open_entry_pr", rfc_slug=slug, branch_name=branch,
|
||||
pr_number=pr["number"], details={"pr_title": pr_title})
|
||||
return pr
|
||||
|
||||
# ----- Meta repo: metadata-pane PRs (§9.5) -----
|
||||
|
||||
async def open_metadata_pr(
|
||||
|
||||
Reference in New Issue
Block a user