Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix git check: back on top #2329

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions projects/optic/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down