Skip to content

Commit

Permalink
Merge pull request #497 from snyk/fix/azure-repos-ignore-disabled
Browse files Browse the repository at this point in the history
fix: ignore disabled azure repos from listing
  • Loading branch information
novalex authored Nov 18, 2024
2 parents 7c54e54 + 0afee01 commit 89889e0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/lib/source-handlers/azure/list-repos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface AzureReposResponse {
name: string;
project: { name: string };
defaultBranch: string;
isDisabled: boolean;
}[];
}
export async function fetchAllRepos(
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/lib/fixtures/azure/org-repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"remoteUrl": "https://dev.azure.com/remoteUrl",
"sshUrl": "",
"webUrl": "https://dev.azure.com/remoteUrl",
"isDisabled": false
"isDisabled": true
}
],
"count": 3
Expand Down
2 changes: 1 addition & 1 deletion test/lib/source-handlers/azure/azure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion test/system/orgs:data/gitlab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('General `snyk-api-import orgs:data <...>`', () => {
expect(stderr).toEqual('');
expect(err).toBeNull();
expect(stdout).toMatch(
'Found 7 group(s). Written the data to file: group-hello-gitlab-orgs.json',
'Found 9 group(s). Written the data to file: group-hello-gitlab-orgs.json',
);
deleteFiles([
path.resolve(__dirname, `group-${groupId}-gitlab-orgs.json`),
Expand Down

0 comments on commit 89889e0

Please sign in to comment.