From cc2e36419627b4350c7feb3797b0d64877e5c850 Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Mon, 12 Oct 2020 22:41:20 -0400 Subject: [PATCH 1/7] =?UTF-8?q?Don=E2=80=99t=20run=20`bypass-checks`=20on?= =?UTF-8?q?=20non=20"run"=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/features/bypass-checks.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/features/bypass-checks.tsx b/source/features/bypass-checks.tsx index 776a3017ee0..9cc0d346b0f 100644 --- a/source/features/bypass-checks.tsx +++ b/source/features/bypass-checks.tsx @@ -7,7 +7,13 @@ import * as api from '../github-helpers/api'; import {getRepoURL} from '../github-helpers'; async function bypass(detailsLink: HTMLAnchorElement): Promise { - const runId = new URLSearchParams(detailsLink.search).get('check_run_id') ?? detailsLink.pathname.split('/').pop()!; + const [actionType, splitRunid] = detailsLink.pathname.split('/').splice(-2); + const runId = new URLSearchParams(detailsLink.search).get('check_run_id') ?? splitRunid; + + if (!Number.parseInt(runId, 10) || actionType !== 'run') { + return; + } + const directLink = await api.v3(`repos/${getRepoURL()}/check-runs/${runId}`); detailsLink.href = directLink.details_url; } From 567b797c32887cd99014fae055fee8be2d4162b3 Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Tue, 13 Oct 2020 07:55:16 -0400 Subject: [PATCH 2/7] Use Regex --- source/features/bypass-checks.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/features/bypass-checks.tsx b/source/features/bypass-checks.tsx index 9cc0d346b0f..ef933843bc0 100644 --- a/source/features/bypass-checks.tsx +++ b/source/features/bypass-checks.tsx @@ -7,10 +7,9 @@ import * as api from '../github-helpers/api'; import {getRepoURL} from '../github-helpers'; async function bypass(detailsLink: HTMLAnchorElement): Promise { - const [actionType, splitRunid] = detailsLink.pathname.split('/').splice(-2); - const runId = new URLSearchParams(detailsLink.search).get('check_run_id') ?? splitRunid; - - if (!Number.parseInt(runId, 10) || actionType !== 'run') { + const runId = /runs\/\d*$/.exec(detailsLink.pathname) ? + detailsLink.pathname.split('/').pop() : new URLSearchParams(detailsLink.search).get('check_run_id'); + if (!runId) { return; } From da02105d34700a9a88c44d7339326d4d525b8c5b Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Tue, 13 Oct 2020 08:00:46 -0400 Subject: [PATCH 3/7] The comment --- source/features/bypass-checks.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/features/bypass-checks.tsx b/source/features/bypass-checks.tsx index ef933843bc0..2e61d3ce4de 100644 --- a/source/features/bypass-checks.tsx +++ b/source/features/bypass-checks.tsx @@ -7,7 +7,7 @@ import * as api from '../github-helpers/api'; import {getRepoURL} from '../github-helpers'; async function bypass(detailsLink: HTMLAnchorElement): Promise { - const runId = /runs\/\d*$/.exec(detailsLink.pathname) ? + const runId = /runs\/\d*$/.exec(detailsLink.pathname) ? // Exclude any URL that does not end with runs. They already link to its own direct page. detailsLink.pathname.split('/').pop() : new URLSearchParams(detailsLink.search).get('check_run_id'); if (!runId) { return; From 27d4cd16f780a9b27784d062e245886cb5af7db2 Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Tue, 13 Oct 2020 18:57:12 -0400 Subject: [PATCH 4/7] Use page detect --- source/features/bypass-checks.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/features/bypass-checks.tsx b/source/features/bypass-checks.tsx index 2e61d3ce4de..0462e4fd841 100644 --- a/source/features/bypass-checks.tsx +++ b/source/features/bypass-checks.tsx @@ -7,8 +7,8 @@ import * as api from '../github-helpers/api'; import {getRepoURL} from '../github-helpers'; async function bypass(detailsLink: HTMLAnchorElement): Promise { - const runId = /runs\/\d*$/.exec(detailsLink.pathname) ? // Exclude any URL that does not end with runs. They already link to its own direct page. - detailsLink.pathname.split('/').pop() : new URLSearchParams(detailsLink.search).get('check_run_id'); + const runId = pageDetect.isActionJobRun(detailsLink) ? detailsLink.pathname.split('/').pop() :// https://github.com/xojs/xo/runs/1104625522 + new URLSearchParams(detailsLink.search).get('check_run_id'); // https://github.com/sindresorhus/refined-github/pull/3629/checks?check_run_id=1223857819 if (!runId) { return; } From ddedf3367e02c40b4dc3a7147b7ae29e06be8970 Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Tue, 13 Oct 2020 22:35:46 -0400 Subject: [PATCH 5/7] update `github-url-detection` --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 979a5f83691..46b468a063b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6545,9 +6545,9 @@ "integrity": "sha512-opDF2E8j+mAEE01XW7GaVsPNwH5Lj73BcuOI2WW5OdIPIZX84k90pCHauQ4VDnS8qyfswIyUIU60R0tBBOJ/zA==" }, "github-url-detection": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/github-url-detection/-/github-url-detection-4.1.0.tgz", - "integrity": "sha512-1toaBYS47tupRpoxML5xkezV6E/ucgMicCpglrQBzIxhrRPd8tyc8cZMx4OHXxflIa8yNsPa40HIr1U0nsOLOA==" + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/github-url-detection/-/github-url-detection-4.1.1.tgz", + "integrity": "sha512-86pew+dkFEyPZL+M5XL47s2AIM1QibpzaKR5lf4wA2EwUrrDdDwf79n+FebvSncvNePSrpuIH8ksZW3aI8v/6g==" }, "glob": { "version": "7.1.6", diff --git a/package.json b/package.json index 23a37e62b84..d1976cf24d7 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "fit-textarea": "^2.0.0", "flat-zip": "^1.0.1", "github-reserved-names": "^2.0.0", - "github-url-detection": "^4.1.0", + "github-url-detection": "^4.1.1", "image-promise": "^7.0.1", "indent-textarea": "^2.0.2", "linkify-issues": "^2.0.0", From ee763a523c55ad7f88f83ae30526bffb03f9c5f6 Mon Sep 17 00:00:00 2001 From: yakov116 <16872793+yakov116@users.noreply.github.com> Date: Wed, 14 Oct 2020 05:38:54 -0400 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Federico --- source/features/bypass-checks.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/features/bypass-checks.tsx b/source/features/bypass-checks.tsx index 0462e4fd841..35306b5457d 100644 --- a/source/features/bypass-checks.tsx +++ b/source/features/bypass-checks.tsx @@ -7,9 +7,11 @@ import * as api from '../github-helpers/api'; import {getRepoURL} from '../github-helpers'; async function bypass(detailsLink: HTMLAnchorElement): Promise { - const runId = pageDetect.isActionJobRun(detailsLink) ? detailsLink.pathname.split('/').pop() :// https://github.com/xojs/xo/runs/1104625522 + const runId = pageDetect.isActionJobRun(detailsLink) ? + detailsLink.pathname.split('/').pop() : // https://github.com/xojs/xo/runs/1104625522 new URLSearchParams(detailsLink.search).get('check_run_id'); // https://github.com/sindresorhus/refined-github/pull/3629/checks?check_run_id=1223857819 if (!runId) { + // Sometimes the URL doesn't point to Checks at all return; } From 6d9ffd36231e825f1e3ce4e1a7e0e8297663a767 Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Tue, 13 Oct 2020 22:35:46 -0400 Subject: [PATCH 7/7] Revert "update `github-url-detection`" This reverts commit ddedf3367e02c40b4dc3a7147b7ae29e06be8970. --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46b468a063b..979a5f83691 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6545,9 +6545,9 @@ "integrity": "sha512-opDF2E8j+mAEE01XW7GaVsPNwH5Lj73BcuOI2WW5OdIPIZX84k90pCHauQ4VDnS8qyfswIyUIU60R0tBBOJ/zA==" }, "github-url-detection": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/github-url-detection/-/github-url-detection-4.1.1.tgz", - "integrity": "sha512-86pew+dkFEyPZL+M5XL47s2AIM1QibpzaKR5lf4wA2EwUrrDdDwf79n+FebvSncvNePSrpuIH8ksZW3aI8v/6g==" + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/github-url-detection/-/github-url-detection-4.1.0.tgz", + "integrity": "sha512-1toaBYS47tupRpoxML5xkezV6E/ucgMicCpglrQBzIxhrRPd8tyc8cZMx4OHXxflIa8yNsPa40HIr1U0nsOLOA==" }, "glob": { "version": "7.1.6", diff --git a/package.json b/package.json index d1976cf24d7..23a37e62b84 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "fit-textarea": "^2.0.0", "flat-zip": "^1.0.1", "github-reserved-names": "^2.0.0", - "github-url-detection": "^4.1.1", + "github-url-detection": "^4.1.0", "image-promise": "^7.0.1", "indent-textarea": "^2.0.2", "linkify-issues": "^2.0.0",