Skip to content

Commit

Permalink
Fixes API result transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeibbb committed Dec 27, 2024
1 parent ae12d9f commit 7970554
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/plus/integrations/providers/gitlab/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ import { fromGitLabMergeRequest, fromGitLabMergeRequestREST, fromGitLabMergeRequ
const gitlabUserIdPrefix = 'gid://gitlab/User/';
const gitlabMergeRequestIdPrefix = 'gid://gitlab/MergeRequest/';

function buildGitLabUserId(id: string | undefined): string | undefined {
return id?.startsWith(gitlabUserIdPrefix) ? id.substring(gitlabUserIdPrefix.length) : id;
function buildGitLabUserId(id: string | number | undefined): string | undefined {
return typeof id === 'string' && id?.startsWith(gitlabUserIdPrefix)
? id.substring(gitlabUserIdPrefix.length)
: String(id);
}

export class GitLabApi implements Disposable {
Expand Down
5 changes: 4 additions & 1 deletion src/plus/integrations/providers/gitlab/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export interface GitLabMergeRequestFull extends GitLabMergeRequest {
headSha: string;
} | null;
project: GitLabRepositoryStub;
sourceProject: GitLabRepositoryStub;
sourceProject: GitLabRepositoryStub | null;
}

export type GitLabMergeRequestState = 'opened' | 'closed' | 'locked' | 'merged';
Expand Down Expand Up @@ -211,6 +211,9 @@ export function fromGitLabMergeRequest(pr: GitLabMergeRequestFull, provider: Pro
}

function fromGitLabMergeRequestRefs(pr: GitLabMergeRequestFull): PullRequestRefs | undefined {
if (pr.sourceProject == null) {
return undefined;
}
return {
base: {
owner: getRepoNamespace(pr.sourceProject.fullPath),
Expand Down

0 comments on commit 7970554

Please sign in to comment.