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

Use API for bypass-checks #3629

Merged
merged 10 commits into from Oct 9, 2020
19 changes: 10 additions & 9 deletions source/features/bypass-checks.tsx
@@ -1,19 +1,20 @@
import mem from 'mem';
import onetime from 'onetime';
import {observe} from 'selector-observer';
import * as pageDetect from 'github-url-detection';

import features from '.';
import fetchDom from '../helpers/fetch-dom';
import * as api from '../github-helpers/api';
import {getRepositoryInfo} from '../github-helpers';

async function bypass(detailsLink: HTMLAnchorElement): Promise<void> {
const directLink = await fetchDom<HTMLAnchorElement>(
detailsLink.href,
'[data-hydro-click*="check_suite.external_click"]'
);
const getDirectLink = mem(async (runNumber: number): Promise<string> => {
const directLink = await api.v3(`https://api.github.com/repos/${getRepositoryInfo()!.owner!}/${getRepositoryInfo()!.name!}/check-runs/${runNumber}`);
fregante marked this conversation as resolved.
Show resolved Hide resolved
return directLink.details_url;
});

if (directLink) {
detailsLink.href = directLink.href;
}
async function bypass(detailsLink: HTMLAnchorElement): Promise<void> {
const runNumber = detailsLink.href.split(/\/|=/).pop();
yakov116 marked this conversation as resolved.
Show resolved Hide resolved
detailsLink.href = await getDirectLink(Number(runNumber));
}

function init(): void {
Expand Down