Merge pull request #8662 from zhammer/zh-gitlab-default-branch-missing
gitlab discovery ignore projects without default_branch
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend': patch
|
||||
---
|
||||
|
||||
Filter out projects with missing `default_branch` from GitLab Discovery.
|
||||
@@ -184,6 +184,13 @@ describe('GitlabDiscoveryProcessor', () => {
|
||||
last_activity_at: '2021-08-05T11:03:05.774Z',
|
||||
web_url: 'https://gitlab.fake/3',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
archived: false,
|
||||
default_branch: undefined, // MISSING DEFAULT BRANCH
|
||||
last_activity_at: '2021-08-05T11:03:05.774Z',
|
||||
web_url: 'https://gitlab.fake/4',
|
||||
},
|
||||
],
|
||||
};
|
||||
default:
|
||||
|
||||
@@ -94,9 +94,16 @@ export class GitLabDiscoveryProcessor implements CatalogProcessor {
|
||||
};
|
||||
for await (const project of projects) {
|
||||
result.scanned++;
|
||||
if (!project.archived) {
|
||||
result.matches.push(project);
|
||||
|
||||
if (project.archived) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (branch === '*' && project.default_branch === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result.matches.push(project);
|
||||
}
|
||||
|
||||
for (const project of result.matches) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
export type GitLabProject = {
|
||||
id: number;
|
||||
default_branch: string;
|
||||
default_branch?: string;
|
||||
archived: boolean;
|
||||
last_activity_at: string;
|
||||
web_url: string;
|
||||
|
||||
Reference in New Issue
Block a user