From 2ac8d387a2e8bc781387a0435badf16891c92bab Mon Sep 17 00:00:00 2001 From: Jamie Magee <JamieMagee@users.noreply.github.com> Date: Tue, 19 Nov 2019 09:13:53 +0100 Subject: [PATCH] =?UTF-8?q?fix(azure):=20select=20a=20merge=20method=20whe?= =?UTF-8?q?n=20there=20are=20no=20policies=20de=E2=80=A6=20(#4730)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Incorrect assumptions around the policy API Fixes #4714 --- lib/platform/azure/azure-helper.ts | 10 ++++++---- test/platform/azure/azure-helper.spec.ts | 15 +-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/lib/platform/azure/azure-helper.ts b/lib/platform/azure/azure-helper.ts index fdec24ecd3..05f3e2ba82 100644 --- a/lib/platform/azure/azure-helper.ts +++ b/lib/platform/azure/azure-helper.ts @@ -254,9 +254,11 @@ export async function getMergeMethod( ) .map(p => p.settings)[0]; - return ( - Object.keys(policyConfigurations) + try { + return Object.keys(policyConfigurations) .map(p => GitPullRequestMergeStrategy[p.slice(5)]) - .find(p => p) || GitPullRequestMergeStrategy.NoFastForward - ); + .find(p => p); + } catch (err) { + return GitPullRequestMergeStrategy.NoFastForward; + } } diff --git a/test/platform/azure/azure-helper.spec.ts b/test/platform/azure/azure-helper.spec.ts index 2fe6cd9503..e4223fafbf 100644 --- a/test/platform/azure/azure-helper.spec.ts +++ b/test/platform/azure/azure-helper.spec.ts @@ -349,20 +349,7 @@ describe('platform/azure/helpers', () => { azureApi.policyApi.mockImplementationOnce( () => ({ - getPolicyConfigurations: jest.fn(() => [ - { - settings: { - scope: [ - { - repositoryId: '', - }, - ], - }, - type: { - id: 'fa4e907d-c16b-4a4c-9dfa-4916e5d171ab', - }, - }, - ]), + getPolicyConfigurations: jest.fn(() => []), } as any) ); expect(await azureHelper.getMergeMethod('', '')).toEqual( -- GitLab