-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Search for GitLab PRs in Launchpad #3795
base: main
Are you sure you want to change the base?
Conversation
In the last commit I'm grouping detected PR-identity by providers, because thought that if we know that an URL matches to a GitLab then no need to search for it in GitHub. But if it looks too compicated, then then last commit can be rejected. |
1c0746a
to
0feb173
Compare
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.
As it stands, this doesn't quite feel ready. The utils and test files that are provider-specific should be organized into provider-specific directories. The url identity being a mapped object by provider id feels confusing - the identity itself should just come in on the function. Some of the changes to the PR utils need either explanation or rewrite to make more sense (why are we defining an undefined const and then returning it without touching it?). The same function being defined in the PR utils but then also implemented specifically for integrations doesn't quite make sense to me. The checkoutable
logic in launchpad shouldn't be necessary - we should always have at least a defined head ref and remote url for a PR, or else we're not fetching enough info.
Can talk on this further on your return.
0feb173
to
e58350a
Compare
e58350a
to
8f03c1c
Compare
0b3b49e
to
3cb31d9
Compare
3cb31d9
to
5d901ee
Compare
5d901ee
to
480bb3d
Compare
480bb3d
to
ae12d9f
Compare
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.
gh pr checkout 3795
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.
@@ -556,7 +557,7 @@ export abstract class IntegrationBase< | |||
const connected = this.maybeConnected ?? (await this.isConnected()); | |||
if (!connected) return undefined; | |||
|
|||
const pr = this.container.cache.getPullRequest(id, resource, this, () => ({ | |||
const pr = await this.container.cache.getPullRequest(id, resource, this, () => ({ |
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 is unnecessary since we return the promise in the next line, similar to other cases. If anything, I would suggest instead that we just combine the two lines to return this.container.cache.get...
and do the same in other places where this pattern occurs across the file.
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.
I did it because I set a breakpoint at this place it was convenient to see a resolved promise.
@@ -1361,4 +1362,6 @@ export abstract class HostingIntegration< | |||
repos?: T[], | |||
cancellation?: CancellationToken, | |||
): Promise<PullRequest[] | undefined>; | |||
|
|||
getPullRequestIdentityFromMaybeUrl?(search: string): PullRequestUrlIdentity | undefined; |
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.
Let's follow a similar pattern for generic and provider-specific function implementation and naming here as we do for other functions, in case we want to expand on the base logic later:
- Have a
protected getProviderPullRequestIdentityFromMaybeUrl
that can be implemented by specific providers (i.e. GitHub, GitLab, etc.) - Have a
getPullRequestIdentityFromMaybeUrl
that, for now, just doesreturn getProviderPullRequestIdentityFromMaybeUrl
and later if we want, we can layer in caching there.
); | ||
} | ||
|
||
async getPullRequestIdentityFromMaybeUrl( |
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.
I suggest calling this one getPullRequestIdentityFromSearch
to avoid making it seem as if line 607 is a recursive call to the same function.
#3788
Description
Checklist
Fixes $XXX -
orCloses #XXX -
prefix to auto-close the issue that your PR addresses