Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Thanks for contributing! 🦋🙌
- [](# "linkify-commit-sha") [Adds link to non-PR commit when visiting a PR commit.](https://user-images.githubusercontent.com/101152/42968387-606b23f2-8ba3-11e8-8a4b-667bddc8d33c.png)
- [](# "pr-filters") [Adds Checks and Draft PR dropdown filters in PR lists.](https://user-images.githubusercontent.com/202916/74453250-6d9de200-4e82-11ea-8fd4-7c0de57e001a.png)
- [](# "pr-approvals-count") [Shows color-coded review counts in PR lists.](https://user-images.githubusercontent.com/1402241/33474535-a814ee78-d6ad-11e7-8f08-a8b72799e376.png)
- [](# "pr-branches") [Shows head and base branches in PR lists if they’re significant.](https://user-images.githubusercontent.com/1402241/51428391-ae9ed500-1c35-11e9-8e54-6b6a424fede4.png)
- [](# "highlight-non-default-base-branch") [Shows the base branch in PR lists if it’s not the default branch.](https://user-images.githubusercontent.com/1402241/88480306-39f4d700-cf4d-11ea-9e40-2b36d92d41aa.png)
- [](# "remove-checks-tab") Hides the `Checks` tab if it’s empty, unless you’re the owner.
- [](# "hide-inactive-deployments") [Hides inactive deployments.](https://github.com/sindresorhus/refined-github/issues/1144)
- [](# "previous-next-commit-buttons") [Adds duplicate commit navigation buttons at the bottom of the `Commits` tab page.](https://user-images.githubusercontent.com/24777/41755271-741773de-75a4-11e8-9181-fcc1c73df633.png)
Expand Down
76 changes: 76 additions & 0 deletions source/features/highlight-non-default-base-branch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'dom-chef';
import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import PullRequestIcon from 'octicon/git-pull-request.svg';

import features from '.';
import * as api from '../github-helpers/api';
import getDefaultBranch from '../github-helpers/get-default-branch';
import {getRepositoryInfo, getRepoGQL} from '../github-helpers';

type BranchInfo = {
baseRef: string;
baseRefName: string;
};

function buildQuery(issueIds: string[]): string {
return `
repository(${getRepoGQL()}) {
${issueIds.map(id => `
${id}: pullRequest(number: ${id.replace(/\D/g, '')}) {
baseRef {id}
baseRefName
}
`).join('\n')}
}
`;
}

async function init(): Promise<false | void> {
const prLinks = select.all('.js-issue-row .js-navigation-open[data-hovercard-type="pull_request"]');
if (prLinks.length === 0) {
return false;
}

const currentRepository = getRepositoryInfo();
const query = buildQuery(prLinks.map(pr => pr.id));
const [data, defaultBranch] = await Promise.all([
api.v4(query),
getDefaultBranch()
]);

for (const prLink of prLinks) {
const pr: BranchInfo = data.repository[prLink.id];
if (pr.baseRefName === defaultBranch) {
continue;
}

const branch = pr.baseRef && `/${currentRepository.owner!}/${currentRepository.name!}/tree/${pr.baseRefName}`;

prLink.parentElement!.querySelector('.text-small.text-gray')!.append(
<span className="issue-meta-section d-inline-block">
<PullRequestIcon/>
{' To '}
<span
className="commit-ref css-truncate user-select-contain mb-n1"
style={(branch ? {} : {textDecoration: 'line-through'})}
>
<a title={branch ? pr.baseRefName : 'Deleted'} href={branch}>
{pr.baseRefName}
</a>
</span>
</span>
);
}
}

void features.add({
id: __filebasename,
description: 'Shows the base branch in PR lists if it’s not the default branch.',
screenshot: 'https://user-images.githubusercontent.com/1402241/88480306-39f4d700-cf4d-11ea-9e40-2b36d92d41aa.png'
}, {
include: [
pageDetect.isRepoConversationList
],
init
});
155 changes: 0 additions & 155 deletions source/features/pr-branches.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion source/refined-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ import './features/show-followers-you-know';
import './features/show-user-top-repositories';
import './features/set-default-repositories-type-to-sources';
import './features/user-profile-follower-badge';
import './features/pr-branches';
import './features/highlight-non-default-base-branch';
import './features/mark-private-orgs';
import './features/linkify-commit-sha';
import './features/bypass-checks';
Expand Down