summaryrefslogtreecommitdiff
path: root/source/features/linkify-branch-references.tsx
blob: ad813ea6130da0f11d1d552d9a2ec9cd910a8669 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import React from 'dom-chef';
import elementReady from 'element-ready';
import * as pageDetect from 'github-url-detection';

import {wrap} from '../helpers/dom-utils';
import features from '.';
import {buildRepoURL} from '../github-helpers';

async function init(): Promise<void | false> {
	const element = await elementReady('.branch-name');
	if (!element) {
		return false;
	}

	const branchUrl = buildRepoURL('tree', element.textContent!);
	wrap(element.closest('.branch-name')!, <a href={branchUrl}/>);
}

void features.add(__filebasename, {
	include: [
		pageDetect.isQuickPR
	],
	init
});