Looking Gitlab user search failure and proceeding with MR creation

Signed-off-by: Lilly Holden <lholden@adaptavist.com>
This commit is contained in:
Lilly Holden
2022-07-18 13:42:25 +01:00
parent e1a08d872c
commit 67f5e019da
2 changed files with 42 additions and 2 deletions
@@ -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,
},
);
});
});
});
@@ -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.`,
);
}
}