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

Further improve branch getter function #4187

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f6630c5
Fix GitHubURL - excluding PR Files
yakov116 Apr 1, 2021
cb1e4f3
Fix tests
yakov116 Apr 1, 2021
ca22fb3
Please check for typo before committing
yakov116 Apr 1, 2021
c80fb13
Fix it for now
yakov116 Apr 1, 2021
eb24a4d
Merge remote-tracking branch 'upstream/githuburl' into githuburl
yakov116 Apr 1, 2021
db42e67
One BIG Mess
yakov116 Apr 1, 2021
83e4980
Lets use the title
yakov116 Apr 1, 2021
2a58301
Merge remote-tracking branch 'upstream/main' into githuburl
yakov116 Apr 5, 2021
4401857
Start fixing
yakov116 Apr 5, 2021
69ef080
Merge branch 'main' into githuburl
yakov116 Apr 6, 2021
659e62e
fix some more
yakov116 Apr 6, 2021
1a04cdd
Exclude pr files
yakov116 Apr 6, 2021
1ca241a
Merge branch 'main' into githuburl
yakov116 Apr 9, 2021
04b7396
Fix some more
yakov116 Apr 9, 2021
9e70957
Fix test for now
yakov116 Apr 9, 2021
44e1a11
Merge remote-tracking branch 'sindresorhus/main' into githuburl
yakov116 Apr 11, 2021
296b022
More cleanup
yakov116 Apr 11, 2021
4254949
Move to its own file
yakov116 Apr 11, 2021
7496845
Fix test
yakov116 Apr 11, 2021
068b21b
Small fix
yakov116 Apr 11, 2021
38bb092
Update comment
yakov116 Apr 11, 2021
a673cb3
Lint
yakov116 Apr 11, 2021
6318630
Lint
yakov116 Apr 12, 2021
f4f8601
Fixup `more-dropdown`
yakov116 Apr 12, 2021
179db54
Lint
yakov116 Apr 12, 2021
e0e4364
Fix `latest-tag-button`
yakov116 Apr 12, 2021
a636300
Add `get branch and filePath from search` test
yakov116 Apr 12, 2021
c6ff873
Update source/github-helpers/index.ts
yakov116 Apr 12, 2021
bc9d068
Update source/github-helpers/index.ts
yakov116 Apr 12, 2021
8b3efcb
Update source/features/more-dropdown.tsx
yakov116 Apr 12, 2021
89b91a6
Not sure what I did here
yakov116 Apr 12, 2021
2f4b63c
Add comment
yakov116 Apr 12, 2021
146190a
Undo TS change
fregante Apr 18, 2021
315f2ab
Update default slashed branch test
fregante Apr 18, 2021
f43511d
Use correct /find/ URL
fregante Apr 18, 2021
dbd0afc
Waiting for element-ready@6
fregante Apr 18, 2021
ccaeeef
Restore index.tsx
fregante Apr 18, 2021
5961155
Merge remote-tracking branch 'upstream/main' into githuburl
yakov116 Apr 19, 2021
62e24d3
Revert "Move to its own file"
yakov116 Apr 19, 2021
586361b
Fix import
yakov116 Apr 19, 2021
17381b8
Move TODO date
yakov116 Apr 19, 2021
c9b0af6
Merge branch 'main' into githuburl
yakov116 Apr 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions source/github-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,25 @@ Example tag content on public repositories: https://github.com/sindresorhus/refi
Example tag content on private repositories https://github.com/private/private/commits/master.atom?token=AEAXKWNRHXA2XJ2ZWCMGUUN44LM62
*/
export const getCurrentBranch = (): string | undefined => {
// Example title: 'tejanium/refined-github:bra/nch' or just 'local-branch`
if (pageDetect.isPRFiles()) {
fregante marked this conversation as resolved.
Show resolved Hide resolved
return select('.head-ref a')!.title.replace(/^[^:]+:/, '');
}

// I dont know regex HELP PLEASE
if (document.title.includes(' at ')) {
return document.title.split(' at ')[1].split(' ·')[0];
}

// .last needed for #2799
const feedLink = select.last('link[type="application/atom+xml"]');
fregante marked this conversation as resolved.
Show resolved Hide resolved
yakov116 marked this conversation as resolved.
Show resolved Hide resolved
// The feedLink is not available on `isIssue` #3641
if (!feedLink) {
const findLink = select.last('a[data-hotkey="t"]');

if (!feedLink && !findLink) {
return;
}

return new URL(feedLink.href)
return new URL(feedLink?.href ?? decodeURIComponent(findLink!.href))
.pathname
.split('/')
.slice(4) // Drops the initial /user/repo/route/ part
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ const {window} = new JSDOM('…');
(global as any).URL = window.URL;

document.head.insertAdjacentHTML('beforeend', '<link href="https://github.com/avajs/ava/commits/master.atom" rel="alternate" title="Recent Commits to ava:master" type="application/atom+xml">');
document.head.insertAdjacentHTML('beforeend', '<a hidden="" data-hotkey="t" data-pjax="true" href="https://github.com/avajs/ava/find/master"></a>');
fregante marked this conversation as resolved.
Show resolved Hide resolved