From e4960c4675d187ba02483587f200c808812569f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Herv=C3=A9?= Date: Thu, 21 Sep 2023 14:46:44 +0200 Subject: [PATCH] fix git check: back on top (#2329) --- projects/optic/src/commands/run.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/projects/optic/src/commands/run.ts b/projects/optic/src/commands/run.ts index ace73c374b..20c979ad9c 100644 --- a/projects/optic/src/commands/run.ts +++ b/projects/optic/src/commands/run.ts @@ -18,7 +18,7 @@ import { import { compute } from './diff/compute'; import { uploadDiff } from './diff/upload-diff'; import chalk from 'chalk'; -import { alias, flushEvents, trackEvent } from '../segment'; +import { flushEvents, trackEvent } from '../segment'; import { BreakingChangesRuleset } from '@useoptic/standard-rulesets'; import { createOpticClient } from '../client/optic-backend'; import fs from 'fs'; @@ -114,7 +114,7 @@ export function registerRunCommand(cli: Command, config: OpticCliConfig) { cli .command('run') .description( - `Optic's workflow command: lint OpenAPI specifications, search for breaking changes, enforce custom API governance rules, automatically update your specs to match your tests traffic and post a friendly summary to the PR/MR and .` + `Optic's workflow command: run lint rules, breaking change checks, and spec validation. Posts the results to PR/MRs when run in CI.` ) .configureHelp({ commandUsage: usage }) .option( @@ -291,21 +291,10 @@ export const getRunAction = const commentToken = process.env.GITHUB_TOKEN ?? process.env.OPTIC_GITLAB_TOKEN; - const currentBranch = - getGithubBranchName() ?? - process.env.CI_COMMIT_REF_NAME ?? - (await getCurrentBranchName()); - - const currentBranchCloudTag = `gitbranch:${currentBranch}`; - const baseBranch = process.env.GITHUB_BASE_REF ?? process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME; - const cloudTag = baseBranch - ? `gitbranch:${baseBranch}` - : currentBranchCloudTag; - const isPR = config.isInCi && !!baseBranch; trackEvent( @@ -334,6 +323,17 @@ export const getRunAction = return; } + const currentBranch = + getGithubBranchName() ?? + process.env.CI_COMMIT_REF_NAME ?? + (await getCurrentBranchName()); + + const currentBranchCloudTag = `gitbranch:${currentBranch}`; + + const cloudTag = baseBranch + ? `gitbranch:${baseBranch}` + : currentBranchCloudTag; + const authentified = config.isInCi ? await authenticateCI(config) : await authenticateInteractive(config);