feat: add pr create and comment (task 0010)
`pr create` takes --title (required), --body/--body-file, --base, --head,
--assignee, --reviewer, repeatable name-resolved --label, and --milestone.
An omitted --head defaults to the current local branch; an omitted --base to
the repository's default branch. Before creating, an existing open PR for the
same base/head pair short-circuits to `pull_request: { number, url, already:
true }` rather than opening a duplicate; only an open PR does, since a closed
one's branches are free to be proposed again.
`pr comment <n>` posts through the shared issue-comment endpoint and returns
the created comment as `comment: { number, author, created, body }` (ADR 0008),
reporting a 404 as PR_NOT_FOUND since the caller asked about a pull request.
That comment block is now built in one place (src/comment.ts) for both issue
and pr comment, as ADR 0008 requires them to stay identical.
This commit was merged in pull request #4.
This commit is contained in:
@@ -219,6 +219,37 @@ export async function provisionInstance(baseUrl: string): Promise<E2EInstance> {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create `branch` off the default branch, carrying one new file, so that a pull
|
||||
* request opened from it has a real diff to propose.
|
||||
*/
|
||||
export async function seedBranch(instance: E2EInstance, branch: string): Promise<void> {
|
||||
await apiRequest(
|
||||
instance.baseUrl,
|
||||
"POST",
|
||||
`/repos/${instance.owner}/${instance.repo}/contents/${branch}.txt`,
|
||||
instance.token,
|
||||
{
|
||||
content: Buffer.from(`Seeded on ${branch}.\n`).toString("base64"),
|
||||
message: `Seed ${branch}`,
|
||||
new_branch: branch,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** Fetch the repository's open pull requests as Gitea returns them. */
|
||||
export async function fetchOpenPulls(
|
||||
instance: E2EInstance,
|
||||
): Promise<Record<string, unknown>[]> {
|
||||
const res = await apiRequest(
|
||||
instance.baseUrl,
|
||||
"GET",
|
||||
`/repos/${instance.owner}/${instance.repo}/pulls?state=open`,
|
||||
instance.token,
|
||||
);
|
||||
return (await res.json()) as Record<string, unknown>[];
|
||||
}
|
||||
|
||||
/** Fetch a single issue as Gitea returns it, for verifying what a mutation wrote. */
|
||||
export async function fetchIssue(
|
||||
instance: E2EInstance,
|
||||
|
||||
Reference in New Issue
Block a user