Skip to content

Commit

Permalink
Adds search by URL for GitLab Self Managed to the Launchpad
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeibbb committed Jan 17, 2025
1 parent 7134b9c commit 0d463ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/plus/integrations/providers/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,13 @@ abstract class GitLabIntegrationBase<
}

protected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {
return getGitLabPullRequestIdentityFromMaybeUrl(search);
const identity = getGitLabPullRequestIdentityFromMaybeUrl(search);
if (identity == null) return undefined;

return {
...identity,
provider: this.id,
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ suite('Test GitLab PR URL parsing to identity: getPullRequestIdentityFromMaybeUr
: {
ownerAndRepo: ownerAndRepo,
prNumber: prNumber,
provider: 'gitlab',
},
`Parse: ${message} (${JSON.stringify(query)})`,
);
Expand Down
7 changes: 2 additions & 5 deletions src/plus/integrations/providers/gitlab/gitlab.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// That's why this file has been created that can collect more simple functions which
// don't require Container and can be tested.

import { HostingIntegrationId } from '../../../../constants.integrations';
import type { PullRequestUrlIdentity } from '../../../../git/models/pullRequest.utils';

export function isMaybeGitLabPullRequestUrl(url: string): boolean {
Expand All @@ -11,7 +10,7 @@ export function isMaybeGitLabPullRequestUrl(url: string): boolean {

export function getGitLabPullRequestIdentityFromMaybeUrl(
search: string,
): (PullRequestUrlIdentity & { provider: HostingIntegrationId.GitLab }) | undefined {
): Omit<PullRequestUrlIdentity, 'provider'> | undefined {
let ownerAndRepo: string | undefined = undefined;
let prNumber: string | undefined = undefined;

Expand All @@ -28,7 +27,5 @@ export function getGitLabPullRequestIdentityFromMaybeUrl(
}
}

return prNumber != null
? { ownerAndRepo: ownerAndRepo, prNumber: prNumber, provider: HostingIntegrationId.GitLab }
: undefined;
return prNumber != null ? { ownerAndRepo: ownerAndRepo, prNumber: prNumber } : undefined;
}

0 comments on commit 0d463ae

Please sign in to comment.