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

Search for GitLab PRs in Launchpad #3795

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

sergeibbb
Copy link
Member

@sergeibbb sergeibbb commented Nov 25, 2024

#3788

Description

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

@sergeibbb sergeibbb linked an issue Nov 25, 2024 that may be closed by this pull request
@sergeibbb
Copy link
Member Author

@axosoft-ramint

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.

Copy link
Contributor

@axosoft-ramint axosoft-ramint left a 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.

@sergeibbb sergeibbb force-pushed the 3788-launchpad-api-search-for-prs-on-gitlab branch from 0feb173 to e58350a Compare December 18, 2024 13:18
@sergeibbb sergeibbb force-pushed the 3788-launchpad-api-search-for-prs-on-gitlab branch from e58350a to 8f03c1c Compare December 18, 2024 13:30
@sergeibbb sergeibbb force-pushed the 3788-launchpad-api-search-for-prs-on-gitlab branch from 0b3b49e to 3cb31d9 Compare December 26, 2024 19:39
sergeibbb added a commit that referenced this pull request Dec 26, 2024
@sergeibbb sergeibbb force-pushed the 3788-launchpad-api-search-for-prs-on-gitlab branch from 3cb31d9 to 5d901ee Compare December 26, 2024 19:47
sergeibbb added a commit that referenced this pull request Dec 26, 2024
@sergeibbb sergeibbb force-pushed the 3788-launchpad-api-search-for-prs-on-gitlab branch from 5d901ee to 480bb3d Compare December 27, 2024 14:45
sergeibbb added a commit that referenced this pull request Dec 27, 2024
@sergeibbb sergeibbb force-pushed the 3788-launchpad-api-search-for-prs-on-gitlab branch from 480bb3d to ae12d9f Compare December 27, 2024 15:19
Copy link

@CbtSlave CbtSlave left a 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

Copy link
Contributor

@axosoft-ramint axosoft-ramint left a comment

Choose a reason for hiding this comment

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

On testing, the only issue I'm seeing is that owner/repo are not showing up on GitLab search results:

image

They do for GitLab PRs that are not search results.

Apart from that, some minor nitpicks that should be easy to change:

@@ -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, () => ({
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

@axosoft-ramint

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;
Copy link
Contributor

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:

  1. Have a protected getProviderPullRequestIdentityFromMaybeUrl that can be implemented by specific providers (i.e. GitHub, GitLab, etc.)
  2. Have a getPullRequestIdentityFromMaybeUrl that, for now, just does return getProviderPullRequestIdentityFromMaybeUrl and later if we want, we can layer in caching there.

);
}

async getPullRequestIdentityFromMaybeUrl(
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Launchpad: API search for PRs on GitLab
4 participants