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

Improve branch getter function #4190

Merged
merged 6 commits into from
Apr 2, 2021
Merged

Improve branch getter function #4190

merged 6 commits into from
Apr 2, 2021

Conversation

fregante
Copy link
Member

@fregante fregante commented Apr 2, 2021

Replaces #4187

Fixes many

WIP

  • Try to preserve GHE support

@fregante fregante added the bug label Apr 2, 2021
@@ -96,7 +95,10 @@ async function init(): Promise<false | void> {
</a>
);

(await elementReady('#branch-select-menu', {waitForChildren: false}))!.closest('.position-relative')!.after(link);
const branchSelector = await elementReady('#branch-select-menu', {waitForChildren: false});
branchSelector!.closest('.position-relative')!.after(link);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a lint, no changes in this file

@@ -51,9 +53,9 @@ function checkoutOption(remote?: string, remoteType?: 'HTTPS' | 'SSH'): JSX.Elem
className="copyable-terminal-content"
>
<span className="user-select-contain">
{remote && `git remote add ${remote} ${connectionType[remoteType!]}${getPRHeadRepo()!.nameWithOwner}.git\n`}
git fetch {remote ?? 'origin'} {getCurrentBranch()}{'\n'}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage of getCurrentBranch in PRs was ambiguous (there are 2 branches) and not it completely throws when used. It's best to use the splitter above. It can be made into its own helper later.

}

if (!unslashedCommittish) {
console.trace('Branch could not be determined');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can help with future debugging, but it can be noisy.


const [, _user, _repo, type, unslashedCommittish] = pathname.split('/');
if (!type) { // Root
console.trace('Branch could not be determined');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dom query attempt could be added here, maybe similar to what's in #4187

Probably it'll need to be sync due to its usage in a setter of GitHubURL

t.is(getCurrentCommittish(
'/typescript-eslint/typescript-eslint',
'typescript-eslint/typescript-eslint: Monorepo for all the tooling which enables ESLint to support TypeScript'
), undefined);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it makes no attempt to query the DOM. #4187 could help

t.is(getCurrentCommittish(
'/typescript-eslint/typescript-eslint/blame/chore/lerna-4/docs/getting-started/README.md',
'History for docs/getting-started/README.md - typescript-eslint/typescript-eslint'
), 'chore'); // Wrong, but
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this page is the only one that has an RSS feed, it could be fixed.

@fregante
Copy link
Member Author

fregante commented Apr 2, 2021

Untested but should be done, for the current iteration. It's best we merge a solution soon so that most feature resume working

@fregante fregante marked this pull request as ready for review April 2, 2021 17:40
@fregante
Copy link
Member Author

fregante commented Apr 2, 2021

It might work in GHE too. Let's push it to production and see

@fregante fregante merged commit d5336d1 into main Apr 2, 2021
@fregante fregante deleted the use-title branch April 2, 2021 17:54
@fregante
Copy link
Member Author

fregante commented Apr 2, 2021

Final notes:

@fregante fregante restored the use-title branch April 2, 2021 18:01
fregante added a commit that referenced this pull request Apr 2, 2021
@fregante
Copy link
Member Author

fregante commented Apr 2, 2021

Merged too early. Undone. Releasing version anyway

@fregante fregante mentioned this pull request Apr 3, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

1 participant