Add pr show, comment and review commands #4

Merged
kimi-bot-andresmgsl merged 5 commits from add-pr-review-commands into main 2026-07-22 22:24:27 +00:00
2 changed files with 12 additions and 3 deletions
Showing only changes of commit d56e509649 - Show all commits

View file

@ -756,12 +756,12 @@ pr
console.error(`Invalid review event: ${options.event}. Must be approve, request-changes, or comment.`);
process.exit(1);
}
const body = (readBodyOption(options) || '').trim();
if (event !== 'APPROVED' && body.length === 0) {
const rawBody = readBodyOption(options) || '';
if (event !== 'APPROVED' && rawBody.trim().length === 0) {
console.error(`Review event ${options.event} requires a non-empty body. Use -b/--body or --body-file.`);
process.exit(1);
}
await client.createPullRequestReview(options.owner, options.repo, options.number, event, body);
await client.createPullRequestReview(options.owner, options.repo, options.number, event, rawBody);
console.log(`Review submitted on !${options.number}: ${event}.`);
} catch (err) {
console.error(`Failed to submit review: ${err.message}`);

View file

@ -170,3 +170,12 @@ test('createPullRequestReview posts the review event and body', async () => {
assert.equal(body.event, 'APPROVED');
assert.equal(body.body, 'Ship it.');
});
test('createPullRequestReview preserves leading and trailing whitespace in the body', async () => {
const calls = mockFetch(() => jsonResponse({ id: 89 }));
const client = new ForgejoClient('https://forge.test', 'tok');
const rawBody = ' code block prefix\n';
await client.createPullRequestReview('owner', 'repo', 8, 'REQUEST_CHANGES', rawBody);
const body = JSON.parse(calls[0].opts.body);
assert.equal(body.body, rawBody);
});