diff --git a/lib/platform/azure/index.spec.ts b/lib/platform/azure/index.spec.ts index 29b8a88a8abf29a9aba01029cbaefb7cb214b409..7075061c94cf841f1087d58d1c6db779ed9c4f91 100644 --- a/lib/platform/azure/index.spec.ts +++ b/lib/platform/azure/index.spec.ts @@ -5,6 +5,7 @@ import { GitStatusState, PullRequestStatus, } from 'azure-devops-node-api/interfaces/GitInterfaces'; +import { REPOSITORY_ARCHIVED } from '../../constants/error-messages'; import { logger as _logger } from '../../logger'; import { BranchStatus, PrState } from '../../types'; import * as _git from '../../util/git'; @@ -144,6 +145,13 @@ describe('platform/azure/index', () => { name: 'prj2', }, }, + { + name: 'repo3', + project: { + name: 'some', + }, + isDisabled: true, + }, ]), } as any) ); @@ -168,6 +176,14 @@ describe('platform/azure/index', () => { expect(azureApi.gitApi.mock.calls).toMatchSnapshot(); expect(config).toMatchSnapshot(); }); + + it(`throws if repo is disabled`, async () => { + await expect( + initRepo({ + repository: 'some/repo3', + }) + ).rejects.toThrow(REPOSITORY_ARCHIVED); + }); }); describe('getRepoForceRebase', () => { diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 231cc0558d12ab337362e08af2800de46ac845e9..30dcf723aa8d986ceee94b48a8d06c69c0df2aaa 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -11,7 +11,10 @@ import { import delay from 'delay'; import JSON5 from 'json5'; import { PlatformId } from '../../constants'; -import { REPOSITORY_EMPTY } from '../../constants/error-messages'; +import { + REPOSITORY_ARCHIVED, + REPOSITORY_EMPTY, +} from '../../constants/error-messages'; import { logger } from '../../logger'; import { BranchStatus, PrState, VulnerabilityAlert } from '../../types'; import * as git from '../../util/git'; @@ -170,6 +173,10 @@ export async function initRepo({ const repos = await azureApiGit.getRepositories(); const repo = getRepoByName(repository, repos); logger.debug({ repositoryDetails: repo }, 'Repository details'); + if (repo.isDisabled) { + logger.debug('Repository is disabled- throwing error to abort renovation'); + throw new Error(REPOSITORY_ARCHIVED); + } // istanbul ignore if if (!repo.defaultBranch) { logger.debug('Repo is empty');