PEP-73: type the commit author in mock-gitea contents API

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Асель 2026-11-14 18:27:18 +05:00
parent cdc7e62bfc
commit 2939bad87f

View File

@ -478,7 +478,8 @@ export class MockGitea {
if (method === "PUT" && current !== body.sha) return { status: 409, body: { message: `sha does not match [given: ${body.sha}, expected: ${current}]` } };
const blob = git(["hash-object", "-w", "--stdin"], undefined, Buffer.from(String(body.content), "base64").toString("utf8"));
const index = join(mkdtempSync(join(tmpdir(), "mock-gitea-idx-")), "index");
const env = { GIT_INDEX_FILE: index, GIT_AUTHOR_NAME: String(body.author?.name ?? me.login), GIT_AUTHOR_EMAIL: String(body.author?.email ?? "mock@example.invalid"), GIT_COMMITTER_NAME: me.login, GIT_COMMITTER_EMAIL: "mock@example.invalid" };
const author = (body.author ?? {}) as { name?: string; email?: string };
const env = { GIT_INDEX_FILE: index, GIT_AUTHOR_NAME: String(author.name ?? me.login), GIT_AUTHOR_EMAIL: String(author.email ?? "mock@example.invalid"), GIT_COMMITTER_NAME: me.login, GIT_COMMITTER_EMAIL: "mock@example.invalid" };
if (parent) git(["read-tree", parent], env);
git(["update-index", "--add", "--cacheinfo", `100644,${blob},${path}`], env);
const tree = git(["write-tree"], env);