Skip to content

Commit

Permalink
allow overriding ci comment
Browse files Browse the repository at this point in the history
  • Loading branch information
acunniffe committed Jan 7, 2025
1 parent e4231b1 commit 4fa7e1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions projects/optic/src/commands/ci/comment/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const registerCiComment = (cli: Command, config: OpticCliConfig) => {
'--enterprise-base-url <enterprise-base-url>',
'(only for enterprise versions of github or gitlab) - the base url to your enterprise github / gitlab instance'
)
.option('--comment-url <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(
Expand All @@ -60,6 +61,7 @@ export const registerCiComment = (cli: Command, config: OpticCliConfig) => {

type CommonOptions = {
verbose: boolean;
commentUrl: string;
};

type UnvalidatedOptions = CommonOptions & {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions projects/optic/src/commands/ci/comment/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -122,7 +122,7 @@ ${s.apiName}
<td>
${getOperationsText(s.comparison.groupedDiffs, {
webUrl: s.opticWebUrl,
webUrl: options.overrideUrl || s.opticWebUrl,
verbose: options.verbose,
labelJoiner: ',\n',
})}
Expand Down Expand Up @@ -163,7 +163,7 @@ ${
<td>
${s.opticWebUrl ? `[View report](${s.opticWebUrl})` : ''}
${options.overrideUrl || s.opticWebUrl ? `[View report](${options.overrideUrl || s.opticWebUrl})` : ''}
</td>
</tr>`
Expand Down

0 comments on commit 4fa7e1d

Please sign in to comment.