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
Conversation
Good idea, disabled.
That kills the cat. Ensure 2 things:
|
This is going to be very hard its used in 15 features. |
Does this PR also fix #4178? |
No that is |
@fregante ok I figured out a way to make this DOM safe in most cases. The title has the word ' at ' in it on many pages. But I dont know regex so I wrote it... |
One thing to note is that this function only really needs the branch to support branches with slashes. In every other case we really don’t care if it exists or not, it makes no difference (if I remember correctly). So in most cases the branch parser can return undefined and the feature should still work. |
I think you are correct |
Probably my PR will have to be integrated with this. I visited https://github.com/eslint/eslint and there's zero mention of Generally this is not a problem, but |
That's what #4190 is doing at the moment. This PR can be merged in the next version, if relevant |
Parts of this have been added by #4193. Here I'm hoping that we can use the DOM to fill in the details in the remaining case:
This is because on that page:
|
Oh man this is not going to be a fun merge |
Co-authored-by: Federico Brigante <[email protected]>
Co-authored-by: Federico Brigante <[email protected]>
Co-authored-by: Federico Brigante <[email protected]>
🤷 I don't know |
@fregante I tried last night again to figure this out, with no luck. I don't care to close and let someone else attempt. Please do as you see fit. |
What’s missing here other than the open reviews? Also if it’s used by any feature (and if it doesn’t already work), on the file editing page there’s a new place to read the branch name from. https://twitter.com/natfriedman/status/1383169134096093187?s=21 |
The tests, I cant figure out how to make it pass. |
test/github-url.ts
Outdated
@@ -3,6 +3,8 @@ import test from 'ava'; | |||
import './fixtures/globals'; | |||
import GitHubURL from '../source/github-helpers/github-url'; | |||
|
|||
document.head.insertAdjacentHTML('beforeend', '<a hidden="" data-hotkey="t" data-pjax="true" href="https://github.com/avajs/ava/find/master"></a>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document.head.insertAdjacentHTML('beforeend', '<a hidden="" data-hotkey="t" data-pjax="true" href="https://github.com/avajs/ava/find/master"></a>'); | |
document.head.insertAdjacentHTML('beforeend', '<a hidden="" data-hotkey="t" data-pjax="true" href="https://github.com/sindresorhus/refined-github/find/Slash%2Fslash"></a>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this and the .remove() call can't be here. They need to be inside the test()
function that uses it
source/github-helpers/index.ts
Outdated
@@ -34,9 +34,35 @@ export const getCurrentCommittish = (pathname = location.pathname, title = docum | |||
return parsedTitle.groups!.branch; | |||
} | |||
|
|||
// TODO [2021-04-12]: .last needed for #2799 // GHE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO [2021-04-12]: .last needed for #2799 // GHE | |
// TODO [2021-08-12]: .last needed for #2799 // GHE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh god. Hah I meant to write the same day, but in 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add unicorn/expiring-todo-comments: warn
in the xo settings? I don't want it to automatically fail lint.
@@ -289,7 +291,7 @@ test('getCurrentCommittish', t => { | |||
t.is(getCurrentCommittish( | |||
'/typescript-eslint/typescript-eslint/commits/chore/lerna-4/docs/getting-started/README.md', | |||
'History for docs/getting-started/README.md - typescript-eslint/typescript-eslint' | |||
), 'chore'); // Wrong, but | |||
), 'master'); // Uses the feedlink |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only shows that the test is wrong, and thus useless.
For this to be tested correctly, it should have the correct feedLink, added and removed just for this test like we do for data-hotkey="t"
(including the code to add it before the test)
), 'master'); // Uses the feedlink | |
), 'chore/lerna-4'); | |
document.querySelector('the feed link')!.remove(); |
I'm closing this PR because extremely long. Please send a new one if you have time, resolving all the review comments and squashing the commits. Or leave it for someone else because we've gone over the same code several times. |
I will leave it for someone else. |
Fixes #4196
Fixes #4271