From ebbc1f19a2bd2e203886299b80c369560ab287e3 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 4 Jun 2024 16:16:12 +0000 Subject: [PATCH] pr comment --- docs/src/content/docs/reference/cli/commands.md | 4 ++-- packages/cli/src/cli.ts | 4 ++-- packages/cli/src/run.ts | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/src/content/docs/reference/cli/commands.md b/docs/src/content/docs/reference/cli/commands.md index 2b7b3de6c9..ff19317320 100644 --- a/docs/src/content/docs/reference/cli/commands.md +++ b/docs/src/content/docs/reference/cli/commands.md @@ -22,8 +22,8 @@ Options: -od, --out-data output file for data (.jsonl/ndjson will be aggregated). JSON schema information and validation will be included if available. -oa, --out-annotations output file for annotations (.csv will be rendered as csv, .jsonl/ndjson will be aggregated) -ocl, --out-changelog output file for changelogs - -prc, --pull-request-comment [string] create comment on a pull request. (default: "") - -prd, --pull-request-description [string] upsert comment on a pull request description. (default: "") + -prc, --pull-request-comment [string] create comment on a pull request. + -prd, --pull-request-description [string] upsert comment on a pull request description. -prr, --pull-request-reviews create pull request reviews from annotations -j, --json emit full JSON response to output -y, --yaml emit full YAML response to output diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index a785c90371..8be4ee0a59 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -102,11 +102,11 @@ export async function cli() { .option("-ocl, --out-changelog ", "output file for changelogs") .option( "-prc, --pull-request-comment [string]", - "create comment on a pull request.", "" + "create comment on a pull request." ) .option( "-prd, --pull-request-description [string]", - "upsert comment on a pull request description.", "" + "upsert comment on a pull request description." ) .option( "-prr, --pull-request-reviews", diff --git a/packages/cli/src/run.ts b/packages/cli/src/run.ts index 31654f8fab..890a2d1f52 100644 --- a/packages/cli/src/run.ts +++ b/packages/cli/src/run.ts @@ -59,8 +59,8 @@ export async function runScript( outTrace: string outAnnotations: string outChangelogs: string - pullRequestComment: string - pullRequestDescription: string + pullRequestComment: string | boolean + pullRequestDescription: string | boolean pullRequestReviews: boolean outData: string label: string @@ -372,26 +372,30 @@ ${Array.from(files) await githubCreatePullRequestReviews(script, info, res.annotations) } - if (pullRequestComment !== undefined && res.text) { + if (pullRequestComment && res.text) { const info = parseGHTokenFromEnv(process.env) if (info.repository && info.issue) { await githubCreateIssueComment( script, info, res.text, - pullRequestComment || script.id + typeof pullRequestComment === "string" + ? pullRequestComment + : script.id ) } } - if (pullRequestDescription !== undefined && res.text) { + if (pullRequestDescription && res.text) { const info = parseGHTokenFromEnv(process.env) if (info.repository && info.issue) { await githubUpsetPullRequest( script, info, res.text, - pullRequestDescription || script.id + typeof pullRequestDescription === "string" + ? pullRequestDescription + : script.id ) } }