From 779232edfa1823cf2d3d48b140d30c4a88c2aff4 Mon Sep 17 00:00:00 2001 From: Alex Nitu Date: Fri, 15 Nov 2024 09:43:03 +0000 Subject: [PATCH] fix: ignore disabled azure repos from listing --- src/lib/source-handlers/azure/list-repos.ts | 6 +++--- test/lib/fixtures/azure/org-repos.json | 2 +- test/lib/source-handlers/azure/azure.test.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/source-handlers/azure/list-repos.ts b/src/lib/source-handlers/azure/list-repos.ts index f6402cf5..1a6b2f90 100644 --- a/src/lib/source-handlers/azure/list-repos.ts +++ b/src/lib/source-handlers/azure/list-repos.ts @@ -15,6 +15,7 @@ interface AzureReposResponse { name: string; project: { name: string }; defaultBranch: string; + isDisabled: boolean; }[]; } export async function fetchAllRepos( @@ -61,9 +62,8 @@ async function getRepos( Response body: ${JSON.stringify(body)}`); } const { value: repos } = body; - repos.map((repo) => { - const { name, project, defaultBranch } = repo; - if (name && project && project.name && defaultBranch) { + repos.map(({ name, project, defaultBranch, isDisabled }) => { + if (name && project && project.name && defaultBranch && !isDisabled) { repoList.push({ name, owner: project.name, diff --git a/test/lib/fixtures/azure/org-repos.json b/test/lib/fixtures/azure/org-repos.json index dfbd8723..d195b151 100644 --- a/test/lib/fixtures/azure/org-repos.json +++ b/test/lib/fixtures/azure/org-repos.json @@ -58,7 +58,7 @@ "remoteUrl": "https://dev.azure.com/remoteUrl", "sshUrl": "", "webUrl": "https://dev.azure.com/remoteUrl", - "isDisabled": false + "isDisabled": true } ], "count": 3 diff --git a/test/lib/source-handlers/azure/azure.test.ts b/test/lib/source-handlers/azure/azure.test.ts index dc373d28..43994938 100644 --- a/test/lib/source-handlers/azure/azure.test.ts +++ b/test/lib/source-handlers/azure/azure.test.ts @@ -70,7 +70,7 @@ describe('Testing azure-devops interaction', () => { }); test('Test listAzureRepos with one page', async () => { const repos = await listAzureRepos('reposTestOrg', 'https://azure-tests'); - expect(repos).toHaveLength(3); + expect(repos).toHaveLength(2); }); test('listAzureRepos to fail', async () => { expect(async () => {