From 7d60807039e4c3876dcac32ff3f618ee2600e3dd Mon Sep 17 00:00:00 2001
From: Oleg Krivtsov <olegkrivtsov@gmail.com>
Date: Wed, 22 Dec 2021 13:10:24 +0700
Subject: [PATCH] Fix issue (#13225)

---
 lib/platform/azure/index.spec.ts | 16 ++++++++++++++++
 lib/platform/azure/index.ts      |  9 ++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/platform/azure/index.spec.ts b/lib/platform/azure/index.spec.ts
index 29b8a88a8a..7075061c94 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 231cc0558d..30dcf723aa 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');
-- 
GitLab