Merge pull request #8662 from zhammer/zh-gitlab-default-branch-missing

gitlab discovery ignore projects without default_branch
This commit is contained in:
Patrik Oldsberg
2021-12-30 10:46:49 +01:00
committed by GitHub
4 changed files with 22 additions and 3 deletions
+5
View File
@@ -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;