From 4fa7e1d1f37fb76b3ed397022615e3b9cd21fd88 Mon Sep 17 00:00:00 2001 From: Aidan Cunniffe Date: Tue, 7 Jan 2025 12:03:46 +0100 Subject: [PATCH] allow overriding ci comment --- projects/optic/src/commands/ci/comment/comment.ts | 3 +++ projects/optic/src/commands/ci/comment/common.ts | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/projects/optic/src/commands/ci/comment/comment.ts b/projects/optic/src/commands/ci/comment/comment.ts index 51a622c9e6..4e09af88ac 100644 --- a/projects/optic/src/commands/ci/comment/comment.ts +++ b/projects/optic/src/commands/ci/comment/comment.ts @@ -51,6 +51,7 @@ export const registerCiComment = (cli: Command, config: OpticCliConfig) => { '--enterprise-base-url ', '(only for enterprise versions of github or gitlab) - the base url to your enterprise github / gitlab instance' ) + .option('--comment-url ', 'override the url of the comment') .option('--verbose', 'show all operations changed in each API', false) .description('comment on a pull request / merge request') .action( @@ -60,6 +61,7 @@ export const registerCiComment = (cli: Command, config: OpticCliConfig) => { type CommonOptions = { verbose: boolean; + commentUrl: string; }; type UnvalidatedOptions = CommonOptions & { @@ -153,6 +155,7 @@ const getCiCommentAction = await commenter.getComment(COMPARE_SUMMARY_IDENTIFIER); const body = generateCompareSummaryMarkdown({ sha: options.sha }, data, { verbose: options.verbose, + overrideUrl: options.commentUrl, }); if (maybeComment) { diff --git a/projects/optic/src/commands/ci/comment/common.ts b/projects/optic/src/commands/ci/comment/common.ts index 0225250561..a3494a13f9 100644 --- a/projects/optic/src/commands/ci/comment/common.ts +++ b/projects/optic/src/commands/ci/comment/common.ts @@ -82,7 +82,7 @@ const getCaptureIssuesLabel = ({ export const generateCompareSummaryMarkdown = ( commit: { sha: string }, results: CiRunDetails, - options: { verbose: boolean } + options: { verbose: boolean; overrideUrl?: string } ) => { const anyCompletedHasWarning = results.completed.some( (s) => s.warnings.length > 0 @@ -122,7 +122,7 @@ ${s.apiName} ${getOperationsText(s.comparison.groupedDiffs, { - webUrl: s.opticWebUrl, + webUrl: options.overrideUrl || s.opticWebUrl, verbose: options.verbose, labelJoiner: ',\n', })} @@ -163,7 +163,7 @@ ${ -${s.opticWebUrl ? `[View report](${s.opticWebUrl})` : ''} +${options.overrideUrl || s.opticWebUrl ? `[View report](${options.overrideUrl || s.opticWebUrl})` : ''} `