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:
@@ -87,6 +87,17 @@ function classify404(response: HttpResponseLike): AxiError {
|
||||
return axiError(`Not found: ${path}`, "UNKNOWN");
|
||||
}
|
||||
|
||||
/**
|
||||
* The HTTP status of a failed API call, or undefined if the failure was not an
|
||||
* HTTP response at all. For the callers that give one status a meaning of their
|
||||
* own before falling back to {@link classifyHttpError} — a 404 from Gitea's
|
||||
* by-base-head pull lookup, for instance, means "no such pull request exists",
|
||||
* which is an ordinary answer rather than an error.
|
||||
*/
|
||||
export function httpStatus(error: unknown): number | undefined {
|
||||
return isHttpResponseLike(error) ? error.status : undefined;
|
||||
}
|
||||
|
||||
export function classifyHttpError(error: unknown): AxiError {
|
||||
if (error instanceof AxiError) {
|
||||
return error;
|
||||
|
||||
Reference in New Issue
Block a user