Looking Gitlab user search failure and proceeding with MR creation
Signed-off-by: Lilly Holden <lholden@adaptavist.com>
This commit is contained in:
+40
@@ -336,5 +336,45 @@ describe('createGitLabMergeRequest', () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('merge request is successfully created without an assignee when assignee is not found in Gitlab', async () => {
|
||||
const input = {
|
||||
repoUrl: 'gitlab.com?repo=repo&owner=owner',
|
||||
title: 'Create my new MR',
|
||||
branchName: 'new-mr',
|
||||
description: 'This is an important change',
|
||||
removeSourceBranch: false,
|
||||
draft: true,
|
||||
targetPath: 'Subdirectory',
|
||||
assignee: 'Unknown',
|
||||
};
|
||||
mockFs({
|
||||
[workspacePath]: {
|
||||
source: { 'foo.txt': 'Hello there!' },
|
||||
irrelevant: { 'bar.txt': 'Nothing to see here' },
|
||||
},
|
||||
});
|
||||
|
||||
const ctx = {
|
||||
createTemporaryDirectory: jest.fn(),
|
||||
output: jest.fn(),
|
||||
logger: getRootLogger(),
|
||||
logStream: new Writable(),
|
||||
input,
|
||||
workspacePath,
|
||||
};
|
||||
await instance.handler(ctx);
|
||||
|
||||
expect(mockGitlabClient.MergeRequests.create).toHaveBeenCalledWith(
|
||||
'owner/repo',
|
||||
'new-mr',
|
||||
'main',
|
||||
'Create my new MR',
|
||||
{
|
||||
description: 'This is an important change',
|
||||
removeSourceBranch: false,
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -161,8 +161,8 @@ export const createPublishGitlabMergeRequestAction = (options: {
|
||||
const assigneeUser = await api.Users.username(assignee);
|
||||
assigneeId = assigneeUser[0].id;
|
||||
} catch (e) {
|
||||
throw new InputError(
|
||||
`Failed to find gitlab user id for ${assignee}: ${e}`,
|
||||
console.warn(
|
||||
`Failed to find gitlab user id for ${assignee}: ${e}. Proceeding with MR creation without an assignee.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user