From 7f6ac52f1697ce09887176611deeb5fda3cab27c Mon Sep 17 00:00:00 2001 From: Jamie Magee <JamieMagee@users.noreply.github.com> Date: Thu, 2 Jan 2020 16:27:18 +0100 Subject: [PATCH] fix(azure): correct naming for branches (#5087) --- lib/platform/azure/index.ts | 4 +++- .../azure/__snapshots__/index.spec.ts.snap | 16 ++++------------ test/platform/azure/index.spec.ts | 8 ++++---- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index 9cf294746a..3b86b2f6ec 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -280,7 +280,9 @@ export async function findPr( try { const prs = await getPrList(); - prsFiltered = prs.filter(item => item.head.ref === branchName); + prsFiltered = prs.filter( + item => item.sourceRefName === azureHelper.getNewBranchName(branchName) + ); if (prTitle) { prsFiltered = prsFiltered.filter(item => item.title === prTitle); diff --git a/test/platform/azure/__snapshots__/index.spec.ts.snap b/test/platform/azure/__snapshots__/index.spec.ts.snap index 3b810b7a1a..16ce1928c6 100644 --- a/test/platform/azure/__snapshots__/index.spec.ts.snap +++ b/test/platform/azure/__snapshots__/index.spec.ts.snap @@ -52,10 +52,8 @@ Array [ exports[`platform/azure findPr(branchName, prTitle, state) returns pr if found it all state 1`] = ` Object { - "head": Object { - "ref": "branch-a", - }, "number": 1, + "sourceRefName": "refs/heads/branch-a", "state": "closed", "title": "branch a pr", } @@ -63,10 +61,8 @@ Object { exports[`platform/azure findPr(branchName, prTitle, state) returns pr if found it close 1`] = ` Object { - "head": Object { - "ref": "branch-a", - }, "number": 1, + "sourceRefName": "refs/heads/branch-a", "state": "closed", "title": "branch a pr", } @@ -74,10 +70,8 @@ Object { exports[`platform/azure findPr(branchName, prTitle, state) returns pr if found it open 1`] = ` Object { - "head": Object { - "ref": "branch-a", - }, "number": 1, + "sourceRefName": "refs/heads/branch-a", "state": "open", "title": "branch a pr", } @@ -85,10 +79,8 @@ Object { exports[`platform/azure findPr(branchName, prTitle, state) returns pr if found not open 1`] = ` Object { - "head": Object { - "ref": "branch-a", - }, "number": 1, + "sourceRefName": "refs/heads/branch-a", "state": "closed", "title": "branch a pr", } diff --git a/test/platform/azure/index.spec.ts b/test/platform/azure/index.spec.ts index 24744f5a7d..06c54a7d32 100644 --- a/test/platform/azure/index.spec.ts +++ b/test/platform/azure/index.spec.ts @@ -222,7 +222,7 @@ describe('platform/azure', () => { () => ({ number: 1, - head: { ref: 'branch-a' }, + sourceRefName: 'refs/heads/branch-a', title: 'branch a pr', state: 'open', } as any) @@ -254,7 +254,7 @@ describe('platform/azure', () => { () => ({ number: 1, - head: { ref: 'branch-a' }, + sourceRefName: 'refs/heads/branch-a', title: 'branch a pr', state: 'closed', } as any) @@ -286,7 +286,7 @@ describe('platform/azure', () => { () => ({ number: 1, - head: { ref: 'branch-a' }, + sourceRefName: 'refs/heads/branch-a', title: 'branch a pr', state: 'closed', } as any) @@ -318,7 +318,7 @@ describe('platform/azure', () => { () => ({ number: 1, - head: { ref: 'branch-a' }, + sourceRefName: 'refs/heads/branch-a', title: 'branch a pr', state: 'closed', } as any) -- GitLab