feat: add pr view and checks (task 0009)
Add `pr view <n>` and `pr checks <n>`, built on the truncation machinery
and review fetches from earlier slices.
`pr view` uses the three-call fetch pattern (PR + reviews in parallel, then
the head commit's combined status) so `checks`, `comment_count`, and
`review_count` are in the default output; `--comments`, `--reviews`, and
`--full` behave as on `issue view`, with `--reviews` exposing Gitea's
`official`/`stale` fields plus per-review inline comments.
`pr checks <n>` renders the checks summary line and the `{ name, conclusion }`
rows, or the scalar no-CI message when no statuses exist.
The state→conclusion mapping and summary live in a new `src/checks.ts`;
`commentRows` is extracted into `src/comment.ts` and shared with `issue view`.
This commit was merged in pull request #9.
This commit is contained in:
@@ -38,3 +38,30 @@ export function commentItem(
|
||||
body: options.full ? body : truncateBody(body, COMMENT_TRUNCATE_LIMIT, options.host),
|
||||
};
|
||||
}
|
||||
|
||||
export interface CommentRowsOptions {
|
||||
host: string;
|
||||
/** Echo bodies untruncated, as `--full` asks. */
|
||||
full: boolean;
|
||||
now: Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `{ author, created, body }` rows for a `--comments` block, shared by
|
||||
* `issue view` and `pr view`. Each body is cleaned and truncated at 800 chars
|
||||
* unless `full` is set. Ordered author→created→body, matching the block header
|
||||
* both commands render.
|
||||
*/
|
||||
export function commentRows(
|
||||
comments: Comment[],
|
||||
options: CommentRowsOptions,
|
||||
): Record<string, unknown>[] {
|
||||
return comments.map((comment) => {
|
||||
const body = comment.body ?? "";
|
||||
return {
|
||||
author: comment.user?.login ?? "",
|
||||
created: relativeTime(comment.created_at, options.now),
|
||||
body: options.full ? body : truncateBody(body, COMMENT_TRUNCATE_LIMIT, options.host),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user