Fixed a bug in gitlab:group:ensureExists where repos was always set as the root group.
Signed-off-by: Andreas Berger <andreas@berger-ecommerce.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
|
||||
---
|
||||
|
||||
Fixed a bug in `gitlab:group:ensureExists` where `repos` was always set as the root group.
|
||||
+6
-6
@@ -51,17 +51,17 @@ describe('gitlab:group:ensureExists', () => {
|
||||
mockGitlabClient.Groups.search.mockResolvedValue([
|
||||
{
|
||||
id: 1,
|
||||
full_path: 'repos/bar',
|
||||
full_path: 'bar',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
full_path: 'repos/foo',
|
||||
full_path: 'foo',
|
||||
},
|
||||
]);
|
||||
|
||||
mockGitlabClient.Groups.create.mockResolvedValue({
|
||||
id: 3,
|
||||
full_path: 'repos/foo/bar',
|
||||
full_path: 'foo/bar',
|
||||
});
|
||||
|
||||
const config = new ConfigReader({
|
||||
@@ -98,15 +98,15 @@ describe('gitlab:group:ensureExists', () => {
|
||||
mockGitlabClient.Groups.search.mockResolvedValue([
|
||||
{
|
||||
id: 1,
|
||||
full_path: 'repos/bar',
|
||||
full_path: 'bar',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
full_path: 'repos/foo',
|
||||
full_path: 'foo',
|
||||
},
|
||||
{
|
||||
id: 42,
|
||||
full_path: 'repos/foo/bar',
|
||||
full_path: 'foo/bar',
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
+4
-2
@@ -66,10 +66,12 @@ export const createGitlabGroupEnsureExistsAction = (options: {
|
||||
token: token,
|
||||
});
|
||||
|
||||
let currentPath: string = 'repos';
|
||||
let currentPath: string | null = null;
|
||||
let parent: GroupSchema | null = null;
|
||||
for (const pathElement of path) {
|
||||
const fullPath = `${currentPath}/${pathElement}`;
|
||||
const fullPath: string = currentPath
|
||||
? `${currentPath}/${pathElement}`
|
||||
: pathElement;
|
||||
const result = (await api.Groups.search(
|
||||
fullPath,
|
||||
)) as unknown as Array<GroupSchema>; // recast since the return type for search is wrong in the gitbeaker typings
|
||||
|
||||
Reference in New Issue
Block a user