Skip to content

Commit 5c45ccb

Browse files
Kocalfregante
authored andcommitted
Bypass the "Checks" page and go directly to the Travis build when clicking the "Details" links on a PR (#1636)
Fixes #1620 Co-authored-by: Federico Brigante <[email protected]>
1 parent e630310 commit 5c45ccb

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ And [many more…](source/content.css)
180180
- [Hide comments in fewer clicks.](https://user-images.githubusercontent.com/1402241/43039221-1ddc91f6-8d29-11e8-9ed4-93459191a510.gif)
181181
- Use <kbd>←</kbd> and <kbd>→</kbd> to navigate through pages with pagination.
182182
- [Find a user’s most starred repositories in their profile.](https://user-images.githubusercontent.com/1402241/48474026-43e3ae80-e82c-11e8-93de-159ad4c6f283.png)
183+
- [Bypass the "Checks" page and go directly to the Travis build when clicking the "Details" links on a PR](https://user-images.githubusercontent.com/2103975/49071220-c6596e80-f22d-11e8-8a1e-bdcd62aa6ece.png)
183184

184185
### Previously part of Refined GitHub
185186

source/content.js

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import usefulNotFoundPage from './features/useful-not-found-page';
8484
import setDefaultRepositoriesTypeToSources from './features/set-default-repositories-type-to-sources';
8585
import markPrivateOrgs from './features/mark-private-orgs';
8686
import navigatePagesWithArrowKeys from './features/navigate-pages-with-arrow-keys';
87+
import bypassChecksTravis from './features/bypass-checks-travis';
8788

8889
import * as pageDetect from './libs/page-detect';
8990
import {safeElementReady, enableFeature, safeOnAjaxedPages, injectCustomCSS} from './libs/utils';
@@ -306,6 +307,10 @@ function ajaxedPagesHandler() {
306307
if (pageDetect.isPRCommit()) {
307308
enableFeature(linkifyCommitSha);
308309
}
310+
311+
if (pageDetect.isPRConversation()) {
312+
enableFeature(bypassChecksTravis);
313+
}
309314
}
310315

311316
init();
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import select from 'select-dom';
2+
import domify from '../libs/domify';
3+
4+
export default async function () {
5+
// If anything errors, RGH will display the error next to the feature name
6+
await Promise.all(select.all('[href="/apps/travis-ci"]').map(bypass));
7+
}
8+
9+
async function bypass(check) {
10+
const details = select('.status-actions', check.parentNode);
11+
12+
const response = await fetch(details.href, {
13+
credentials: 'include'
14+
});
15+
16+
if (!response.ok) {
17+
return;
18+
}
19+
20+
const dom = domify(await response.text());
21+
// On errored build check pages, there's a link that points
22+
// to the first errored Travis build instead of the current one.
23+
// e.g. the failed "PR build" instead of the "branch build"
24+
// .text-small selects the right one.
25+
const directLink = select('[href^="https://travis-ci.com"].text-small', dom);
26+
details.href = directLink.href;
27+
}

0 commit comments

Comments
 (0)