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

Trying to figure out what's breaking an OLC check #44

Closed
wants to merge 3 commits into from
Closed
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
37 changes: 36 additions & 1 deletion eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// $FlowFixMe: shhhhh
require('@babel/register'); // flow-uncovered-line

const {spawnSync} = require('child_process');

const gitChangedFiles = require('actions-utils/git-changed-files');
const getBaseRef = require('actions-utils/get-base-ref');
//const getBaseRef = require('actions-utils/get-base-ref');
const {cannedGithubErrorMessage} = require('actions-utils/get-base-ref');
const core = require('@actions/core'); // flow-uncovered-line
const {exec} = require('@actions/exec'); // flow-uncovered-line
Expand All @@ -24,6 +26,39 @@ const chalk = require('chalk');

chalk.enabled = !process.env.GITHUB_TOKEN;

const checkRef = ref => spawnSync('git', ['rev-parse', ref, '--']).status === 0;

const validateBaseRef = (baseRef /*:string*/) /*: string | null */ => {

const {stdout, stderr,error) = spawnSync('git', ['rev-parse', ref, '--'], {stdio: 'inherit'});
core.info(stdout);
core.info(stderr);
core.info(error.message);

// It's locally accessible!
if (checkRef(baseRef)) {
return baseRef;
}

// If it's not locally accessible, then it's probably a remote branch
const remote = `refs/remotes/origin/${baseRef}`;
if (checkRef(remote)) {
return remote;
}

// Otherwise return null - no valid ref provided
return null;
};

const getBaseRef = (head /*:string*/ = 'HEAD') /*: string | null */ => {
const {GITHUB_BASE_REF} = process.env;
if (GITHUB_BASE_REF) {
return validateBaseRef(GITHUB_BASE_REF);
} else {
return null;
}
};

/*::
import type {Message} from 'actions-utils/send-report';
import type {Formatter, LintReport, LintResult} from './types.js';
Expand Down
Loading