diff --git a/lib/platform/azure/__snapshots__/index.spec.ts.snap b/lib/platform/azure/__snapshots__/index.spec.ts.snap index 707811098531a5ea7d103bb26c425b5d5684623b..639d7254a5e39ed1e6616e5ae8bcfca94844688c 100644 --- a/lib/platform/azure/__snapshots__/index.spec.ts.snap +++ b/lib/platform/azure/__snapshots__/index.spec.ts.snap @@ -3,11 +3,11 @@ exports[`platform/azure createPr() should create and return a PR object 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #456", "number": 456, "pullRequestId": 456, + "sourceBranch": undefined, "sourceRefName": undefined, "state": "open", "targetBranch": undefined, @@ -17,11 +17,11 @@ Object { exports[`platform/azure createPr() should create and return a PR object from base branch 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #456", "number": 456, "pullRequestId": 456, + "sourceBranch": undefined, "sourceRefName": undefined, "state": "open", "targetBranch": undefined, @@ -34,7 +34,6 @@ Object { "id": 123, }, "body": undefined, - "branchName": undefined, "completionOptions": Object { "deleteSourceBranch": true, "squashMerge": true, @@ -46,6 +45,7 @@ Object { "displayNumber": "Pull Request #456", "number": 456, "pullRequestId": 456, + "sourceBranch": undefined, "sourceRefName": undefined, "state": "open", "targetBranch": undefined, @@ -114,11 +114,11 @@ content", exports[`platform/azure findPr(branchName, prTitle, state) returns pr if found it all state 1`] = ` Object { "body": undefined, - "branchName": "branch-a", "createdAt": undefined, "displayNumber": "Pull Request #1", "number": 1, "pullRequestId": 1, + "sourceBranch": "branch-a", "sourceRefName": "refs/heads/branch-a", "state": "closed", "status": 2, @@ -131,11 +131,11 @@ Object { exports[`platform/azure findPr(branchName, prTitle, state) returns pr if found it close 1`] = ` Object { "body": undefined, - "branchName": "branch-a", "createdAt": undefined, "displayNumber": "Pull Request #1", "number": 1, "pullRequestId": 1, + "sourceBranch": "branch-a", "sourceRefName": "refs/heads/branch-a", "state": "closed", "status": 2, @@ -148,11 +148,11 @@ Object { exports[`platform/azure findPr(branchName, prTitle, state) returns pr if found it open 1`] = ` Object { "body": undefined, - "branchName": "branch-a", "createdAt": undefined, "displayNumber": "Pull Request #1", "number": 1, "pullRequestId": 1, + "sourceBranch": "branch-a", "sourceRefName": "refs/heads/branch-a", "state": "open", "status": 1, @@ -165,11 +165,11 @@ Object { exports[`platform/azure findPr(branchName, prTitle, state) returns pr if found not open 1`] = ` Object { "body": undefined, - "branchName": "branch-a", "createdAt": undefined, "displayNumber": "Pull Request #1", "number": 1, "pullRequestId": 1, + "sourceBranch": "branch-a", "sourceRefName": "refs/heads/branch-a", "state": "merged", "status": 3, @@ -184,7 +184,6 @@ exports[`platform/azure getBranchPr(branchName) should return the pr 1`] = `null exports[`platform/azure getPr(prNo) should return a pr in the right format 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #1234", "hasReviewers": false, @@ -193,6 +192,7 @@ Object { ], "number": 1234, "pullRequestId": 1234, + "sourceBranch": undefined, "sourceRefName": undefined, "state": "open", "targetBranch": undefined, diff --git a/lib/platform/azure/__snapshots__/util.spec.ts.snap b/lib/platform/azure/__snapshots__/util.spec.ts.snap index 6c6623c895bfba5502fc03846b6d573a18d17b81..a5bfccbb793c909bd0e000031055c3bf325e77bd 100644 --- a/lib/platform/azure/__snapshots__/util.spec.ts.snap +++ b/lib/platform/azure/__snapshots__/util.spec.ts.snap @@ -3,10 +3,10 @@ exports[`platform/azure/helpers getRenovatePRFormat should be formated (closed v2) 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #undefined", "number": undefined, + "sourceBranch": undefined, "sourceRefName": undefined, "state": "merged", "status": 3, @@ -17,10 +17,10 @@ Object { exports[`platform/azure/helpers getRenovatePRFormat should be formated (closed) 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #undefined", "number": undefined, + "sourceBranch": undefined, "sourceRefName": undefined, "state": "closed", "status": 2, @@ -31,12 +31,12 @@ Object { exports[`platform/azure/helpers getRenovatePRFormat should be formated (isConflicted) 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #undefined", "isConflicted": true, "mergeStatus": 2, "number": undefined, + "sourceBranch": undefined, "sourceRefName": undefined, "state": "open", "targetBranch": undefined, @@ -46,10 +46,10 @@ Object { exports[`platform/azure/helpers getRenovatePRFormat should be formated (not closed) 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #undefined", "number": undefined, + "sourceBranch": undefined, "sourceRefName": undefined, "state": "open", "status": 1, diff --git a/lib/platform/azure/index.spec.ts b/lib/platform/azure/index.spec.ts index 597de4701c5cf850018e19e7b10c0e4cfc337430..b03401cdd0e80d1ea2aaef5142ed45631464f709 100644 --- a/lib/platform/azure/index.spec.ts +++ b/lib/platform/azure/index.spec.ts @@ -429,7 +429,7 @@ describe('platform/azure', () => { } as any) ); const pr = await azure.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'master', prTitle: 'The Title', prBody: 'Hello world', @@ -450,7 +450,7 @@ describe('platform/azure', () => { } as any) ); const pr = await azure.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'master', prTitle: 'The Title', prBody: 'Hello world', @@ -489,7 +489,7 @@ describe('platform/azure', () => { } as any) ); const pr = await azure.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'dev', prTitle: 'The Title', prBody: 'Hello world', diff --git a/lib/platform/azure/index.ts b/lib/platform/azure/index.ts index b0b9f2369f4a73d42c0977ad805a32109a13b652..5aa8c1436141b618103cee7ed857a325c3a19c29 100644 --- a/lib/platform/azure/index.ts +++ b/lib/platform/azure/index.ts @@ -317,7 +317,7 @@ export async function getBranchStatus( } export async function createPr({ - branchName, + sourceBranch, targetBranch, prTitle: title, prBody: body, @@ -325,7 +325,7 @@ export async function createPr({ draftPR = false, platformOptions, }: CreatePRConfig): Promise<Pr> { - const sourceRefName = getNewBranchName(branchName); + const sourceRefName = getNewBranchName(sourceBranch); const targetRefName = getNewBranchName(targetBranch); const description = azureHelper.max4000Chars(sanitize(body)); const azureApiGit = await azureApi.gitApi(); diff --git a/lib/platform/azure/util.ts b/lib/platform/azure/util.ts index 6f1fc3ec0bc0394d5191790f93ec68f4560a4dde..5863144f0e527fd8813c379dea4ac8071030a7f3 100644 --- a/lib/platform/azure/util.ts +++ b/lib/platform/azure/util.ts @@ -50,7 +50,9 @@ export function getRenovatePRFormat(azurePr: GitPullRequest): AzurePr { const number = azurePr.pullRequestId; const displayNumber = `Pull Request #${number}`; - const branchName = getBranchNameWithoutRefsheadsPrefix(azurePr.sourceRefName); + const sourceBranch = getBranchNameWithoutRefsheadsPrefix( + azurePr.sourceRefName + ); const targetBranch = getBranchNameWithoutRefsheadsPrefix( azurePr.targetRefName ); @@ -69,7 +71,7 @@ export function getRenovatePRFormat(azurePr: GitPullRequest): AzurePr { return { ...azurePr, - branchName, + sourceBranch, state, number, displayNumber, diff --git a/lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap b/lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap index 48e378bd545a5b482a847d2e11e315d2b674eb54..1b8061e8ce02bce39fc9fad73f646478829f85dd 100644 --- a/lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap +++ b/lib/platform/bitbucket-server/__snapshots__/index.spec.ts.snap @@ -1290,9 +1290,9 @@ exports[`platform/bitbucket-server/index endpoint with no path findPr() has pr 1 Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "createdAt": 1547853840016, "number": 5, + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -1386,7 +1386,6 @@ exports[`platform/bitbucket-server/index endpoint with no path getBranchPr() has Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -1396,6 +1395,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -1824,7 +1824,6 @@ exports[`platform/bitbucket-server/index endpoint with no path getPr() canRebase Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -1834,6 +1833,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -1845,7 +1845,6 @@ exports[`platform/bitbucket-server/index endpoint with no path getPr() canRebase Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -1855,6 +1854,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -1866,7 +1866,6 @@ exports[`platform/bitbucket-server/index endpoint with no path getPr() canRebase Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -1876,6 +1875,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -1988,7 +1988,6 @@ exports[`platform/bitbucket-server/index endpoint with no path getPr() gets a PR Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -1998,6 +1997,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -2061,12 +2061,12 @@ Array [ exports[`platform/bitbucket-server/index endpoint with no path getPr() gets a closed PR 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #undefined", "hasReviewers": false, "number": undefined, "reviewers": Array [], + "sourceBranch": undefined, "state": "merged", "targetBranch": undefined, "title": undefined, @@ -2138,9 +2138,9 @@ Array [ Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "createdAt": 1547853840016, "number": 5, + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -5037,9 +5037,9 @@ exports[`platform/bitbucket-server/index endpoint with path findPr() has pr 1`] Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "createdAt": 1547853840016, "number": 5, + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -5133,7 +5133,6 @@ exports[`platform/bitbucket-server/index endpoint with path getBranchPr() has pr Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -5143,6 +5142,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -5571,7 +5571,6 @@ exports[`platform/bitbucket-server/index endpoint with path getPr() canRebase 1` Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -5581,6 +5580,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -5592,7 +5592,6 @@ exports[`platform/bitbucket-server/index endpoint with path getPr() canRebase 2` Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -5602,6 +5601,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -5613,7 +5613,6 @@ exports[`platform/bitbucket-server/index endpoint with path getPr() canRebase 3` Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -5623,6 +5622,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -5735,7 +5735,6 @@ exports[`platform/bitbucket-server/index endpoint with path getPr() gets a PR 1` Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "canMerge": false, "createdAt": 1547853840016, "displayNumber": "Pull Request #5", @@ -5745,6 +5744,7 @@ Object { "reviewers": Array [ "userName2", ], + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", @@ -5808,12 +5808,12 @@ Array [ exports[`platform/bitbucket-server/index endpoint with path getPr() gets a closed PR 1`] = ` Object { "body": undefined, - "branchName": undefined, "createdAt": undefined, "displayNumber": "Pull Request #undefined", "hasReviewers": false, "number": undefined, "reviewers": Array [], + "sourceBranch": undefined, "state": "merged", "targetBranch": undefined, "title": undefined, @@ -5885,9 +5885,9 @@ Array [ Object { "body": "* Line 1 * Line 2", - "branchName": "userName1/pullRequest5", "createdAt": 1547853840016, "number": 5, + "sourceBranch": "userName1/pullRequest5", "state": "open", "targetBranch": "master", "title": "title", diff --git a/lib/platform/bitbucket-server/index.spec.ts b/lib/platform/bitbucket-server/index.spec.ts index 34dca6af473fec1b1fe9032e2e5b3f57825cccab..ca2847e1fc6d4d58a2c1fed7469c561ac2b81170 100644 --- a/lib/platform/bitbucket-server/index.spec.ts +++ b/lib/platform/bitbucket-server/index.spec.ts @@ -1131,7 +1131,7 @@ describe(getName(__filename), () => { .reply(200, prMock(url, 'SOME', 'repo')); const { number: id } = await bitbucket.createPr({ - branchName: 'branch', + sourceBranch: 'branch', targetBranch: 'master', prTitle: 'title', prBody: 'body', @@ -1158,7 +1158,7 @@ describe(getName(__filename), () => { .reply(200, prMock(url, 'SOME', 'repo')); const { number: id } = await bitbucket.createPr({ - branchName: 'branch', + sourceBranch: 'branch', targetBranch: 'master', prTitle: 'title', prBody: 'body', diff --git a/lib/platform/bitbucket-server/index.ts b/lib/platform/bitbucket-server/index.ts index 25a6ac371a2af22a8353df0be4a8e16e829e0564..d048e4fcf2e534e9a1a6b305dbea62b910079888 100644 --- a/lib/platform/bitbucket-server/index.ts +++ b/lib/platform/bitbucket-server/index.ts @@ -295,7 +295,7 @@ const isRelevantPr = ( prTitle: string | null | undefined, state: string ) => (p: Pr): boolean => - p.branchName === branchName && + p.sourceBranch === branchName && (!prTitle || p.title === prTitle) && matchesState(p.state, state); @@ -769,14 +769,14 @@ const escapeHash = (input: string): string => input ? input.replace(/#/g, '%23') : input; export async function createPr({ - branchName, + sourceBranch, targetBranch, prTitle: title, prBody: rawDescription, platformOptions, }: CreatePRConfig): Promise<Pr> { const description = sanitize(rawDescription); - logger.debug(`createPr(${branchName}, title=${title})`); + logger.debug(`createPr(${sourceBranch}, title=${title})`); const base = targetBranch; let reviewers: BbsRestUserRef[] = []; @@ -794,7 +794,7 @@ export async function createPr({ `./rest/default-reviewers/1.0/projects/${config.projectKey}/repos/${ config.repositorySlug }/reviewers?sourceRefId=refs/heads/${escapeHash( - branchName + sourceBranch )}&targetRefId=refs/heads/${base}&sourceRepoId=${id}&targetRepoId=${id}` ) ).body; @@ -808,7 +808,7 @@ export async function createPr({ title, description, fromRef: { - id: `refs/heads/${branchName}`, + id: `refs/heads/${sourceBranch}`, }, toRef: { id: `refs/heads/${base}`, @@ -829,7 +829,7 @@ export async function createPr({ logger.debug( 'Empty pull request - deleting branch so it can be recreated next run' ); - await deleteBranch(branchName); + await deleteBranch(sourceBranch); throw new Error(REPOSITORY_CHANGED); } throw err; diff --git a/lib/platform/bitbucket-server/utils.ts b/lib/platform/bitbucket-server/utils.ts index 5fa338bab8c44c3970a866da30d2ff2499d48c6b..9c438dbf0bf04ba2387ade86e8d3a918af228931 100644 --- a/lib/platform/bitbucket-server/utils.ts +++ b/lib/platform/bitbucket-server/utils.ts @@ -19,7 +19,7 @@ export function prInfo(pr: BbbsRestPr): BbsPr { version: pr.version, number: pr.id, body: pr.description, - branchName: pr.fromRef.displayId, + sourceBranch: pr.fromRef.displayId, targetBranch: pr.toRef.displayId, title: pr.title, state: prStateMapping[pr.state], diff --git a/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap b/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap index 210688c88709c06ffca63bcd8b3edca52774a95e..17a5c002a2964ea77e27d527c71a45ee20761db3 100644 --- a/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap +++ b/lib/platform/bitbucket/__snapshots__/index.spec.ts.snap @@ -381,9 +381,9 @@ Array [ exports[`platform/bitbucket findPr() finds pr 1`] = ` Object { "body": "summary", - "branchName": "branch", "createdAt": "2018-07-02T07:02:25.275030+00:00", "number": 5, + "sourceBranch": "branch", "state": "open", "targetBranch": "master", "title": "title", @@ -420,13 +420,13 @@ Array [ exports[`platform/bitbucket getBranchPr() bitbucket finds PR for branch 1`] = ` Object { "body": "summary", - "branchName": "branch", "canMerge": true, "createdAt": "2018-07-02T07:02:25.275030+00:00", "displayNumber": "Pull Request #5", "hasReviewers": false, "isConflicted": false, "number": 5, + "sourceBranch": "branch", "state": "open", "targetBranch": "master", "title": "title", @@ -809,13 +809,13 @@ Array [ exports[`platform/bitbucket getPr() canRebase 1`] = ` Object { "body": "summary", - "branchName": "branch", "canMerge": true, "createdAt": "2018-07-02T07:02:25.275030+00:00", "displayNumber": "Pull Request #3", "hasReviewers": false, "isConflicted": false, "number": 3, + "sourceBranch": "branch", "state": "open", "targetBranch": "master", "title": "title", @@ -825,13 +825,13 @@ Object { exports[`platform/bitbucket getPr() canRebase 2`] = ` Object { "body": "summary", - "branchName": "branch", "canMerge": true, "createdAt": "2018-07-02T07:02:25.275030+00:00", "displayNumber": "Pull Request #5", "hasReviewers": false, "isConflicted": false, "number": 5, + "sourceBranch": "branch", "state": "open", "targetBranch": "master", "title": "title", @@ -841,13 +841,13 @@ Object { exports[`platform/bitbucket getPr() canRebase 3`] = ` Object { "body": "summary", - "branchName": "branch", "canMerge": true, "createdAt": "2018-07-02T07:02:25.275030+00:00", "displayNumber": "Pull Request #5", "hasReviewers": false, "isConflicted": false, "number": 5, + "sourceBranch": "branch", "state": "open", "targetBranch": "master", "title": "title", @@ -936,13 +936,13 @@ Array [ exports[`platform/bitbucket getPr() exists 1`] = ` Object { "body": "summary", - "branchName": "branch", "canMerge": true, "createdAt": "2018-07-02T07:02:25.275030+00:00", "displayNumber": "Pull Request #5", "hasReviewers": false, "isConflicted": false, "number": 5, + "sourceBranch": "branch", "state": "open", "targetBranch": "master", "title": "title", diff --git a/lib/platform/bitbucket/index.spec.ts b/lib/platform/bitbucket/index.spec.ts index f4a476d17873fff9a5c40b30a1b3ac8e8801cbff..b98c7a1758a4e6426fb495dec1988f72a3c0cce6 100644 --- a/lib/platform/bitbucket/index.spec.ts +++ b/lib/platform/bitbucket/index.spec.ts @@ -642,7 +642,7 @@ describe('platform/bitbucket', () => { .post('/2.0/repositories/some/repo/pullrequests') .reply(200, { id: 5 }); const { number } = await bitbucket.createPr({ - branchName: 'branch', + sourceBranch: 'branch', targetBranch: 'master', prTitle: 'title', prBody: 'body', diff --git a/lib/platform/bitbucket/index.ts b/lib/platform/bitbucket/index.ts index 94b416563886b934f8c5c94bd197880ea79f8e09..ef3f6dc12670090326196185933aa0e327307270 100644 --- a/lib/platform/bitbucket/index.ts +++ b/lib/platform/bitbucket/index.ts @@ -212,7 +212,7 @@ export async function findPr({ const prList = await getPrList(); const pr = prList.find( (p) => - p.branchName === branchName && + p.sourceBranch === branchName && (!prTitle || p.title === prTitle) && matchesState(p.state, state) ); @@ -629,7 +629,7 @@ export function ensureCommentRemoval({ // Creates PR and returns PR number export async function createPr({ - branchName, + sourceBranch, targetBranch, prTitle: title, prBody: description, @@ -659,7 +659,7 @@ export async function createPr({ description: sanitize(description), source: { branch: { - name: branchName, + name: sourceBranch, }, }, destination: { diff --git a/lib/platform/bitbucket/utils.ts b/lib/platform/bitbucket/utils.ts index 2be0b0be52ebec904c24ae03795184ca425d8e16..fa5bbb4589e402e2a8ba0c53f55b5631dc244bbb 100644 --- a/lib/platform/bitbucket/utils.ts +++ b/lib/platform/bitbucket/utils.ts @@ -173,7 +173,7 @@ export function prInfo(pr: PrResponse): Pr { return { number: pr.id, body: pr.summary ? pr.summary.raw : /* istanbul ignore next */ undefined, - branchName: pr.source.branch.name, + sourceBranch: pr.source.branch.name, targetBranch: pr.destination.branch.name, title: pr.title, state: prStates.closed.includes(pr.state) diff --git a/lib/platform/common.ts b/lib/platform/common.ts index f7e03496ba67363ecf9af53ec76b84c1e464e820..74cc54a0aace4ea1a170e424e1c0a0630f05164e 100644 --- a/lib/platform/common.ts +++ b/lib/platform/common.ts @@ -48,7 +48,7 @@ export interface RepoParams { */ export interface Pr { body?: string; - branchName: string; + sourceBranch: string; canMerge?: boolean; canMergeReason?: string; createdAt?: string; @@ -82,7 +82,7 @@ export type PlatformPrOptions = { gitLabAutomerge?: boolean; }; export interface CreatePRConfig { - branchName: string; + sourceBranch: string; targetBranch: string; prTitle: string; prBody: string; diff --git a/lib/platform/gitea/__snapshots__/index.spec.ts.snap b/lib/platform/gitea/__snapshots__/index.spec.ts.snap index 094944432f2b50dc3206a013475ad085042163a3..d455cb8940bf2366c10006c95407751265817ecc 100644 --- a/lib/platform/gitea/__snapshots__/index.spec.ts.snap +++ b/lib/platform/gitea/__snapshots__/index.spec.ts.snap @@ -3,7 +3,6 @@ exports[`platform/gitea createPr should use base branch by default 1`] = ` Object { "body": "pr-body", - "branchName": "pr-branch", "canMerge": true, "createdAt": "2014-04-01T05:14:20Z", "displayNumber": "Pull Request #42", @@ -11,6 +10,7 @@ Object { "isConflicted": false, "number": 42, "sha": "0d9c7726c3d628b7e28af234595cfd20febdbf8e", + "sourceBranch": "pr-branch", "sourceRepo": "some/repo", "state": "open", "targetBranch": "devel", @@ -21,7 +21,6 @@ Object { exports[`platform/gitea createPr should use default branch if requested 1`] = ` Object { "body": "pr-body", - "branchName": "pr-branch", "canMerge": true, "createdAt": "2014-04-01T05:14:20Z", "displayNumber": "Pull Request #42", @@ -29,6 +28,7 @@ Object { "isConflicted": false, "number": 42, "sha": "0d9c7726c3d628b7e28af234595cfd20febdbf8e", + "sourceBranch": "pr-branch", "sourceRepo": "some/repo", "state": "open", "targetBranch": "master", @@ -39,7 +39,6 @@ Object { exports[`platform/gitea getPr should fallback to direct fetching if cache fails 1`] = ` Object { "body": "some random pull request", - "branchName": "some-head-branch", "canMerge": true, "createdAt": "2015-03-22T20:36:16Z", "displayNumber": "Pull Request #1", @@ -47,6 +46,7 @@ Object { "isConflicted": false, "number": 1, "sha": "some-head-sha", + "sourceBranch": "some-head-branch", "sourceRepo": "some/repo", "state": "open", "targetBranch": "some-base-branch", @@ -57,7 +57,6 @@ Object { exports[`platform/gitea getPr should return enriched pull request which exists if open 1`] = ` Object { "body": "some random pull request", - "branchName": "some-head-branch", "canMerge": true, "createdAt": "2015-03-22T20:36:16Z", "displayNumber": "Pull Request #1", @@ -65,6 +64,7 @@ Object { "isConflicted": false, "number": 1, "sha": "some-head-sha", + "sourceBranch": "some-head-branch", "sourceRepo": "some/repo", "state": "open", "targetBranch": "some-base-branch", @@ -83,7 +83,6 @@ exports[`platform/gitea getPrList should filter list by creator 2`] = ` Array [ Object { "body": "some random pull request", - "branchName": "some-head-branch", "canMerge": true, "createdAt": "2015-03-22T20:36:16Z", "displayNumber": "Pull Request #1", @@ -91,6 +90,7 @@ Array [ "isConflicted": false, "number": 1, "sha": "some-head-sha", + "sourceBranch": "some-head-branch", "sourceRepo": "some/repo", "state": "open", "targetBranch": "some-base-branch", @@ -98,7 +98,6 @@ Array [ }, Object { "body": "other random pull request", - "branchName": "other-head-branch", "canMerge": true, "createdAt": "2011-08-18T22:30:38Z", "displayNumber": "Pull Request #2", @@ -106,6 +105,7 @@ Array [ "isConflicted": false, "number": 2, "sha": "other-head-sha", + "sourceBranch": "other-head-branch", "sourceRepo": "some/repo", "state": "closed", "targetBranch": "other-base-branch", @@ -118,7 +118,6 @@ exports[`platform/gitea getPrList should return list of pull requests 1`] = ` Array [ Object { "body": "some random pull request", - "branchName": "some-head-branch", "canMerge": true, "createdAt": "2015-03-22T20:36:16Z", "displayNumber": "Pull Request #1", @@ -126,6 +125,7 @@ Array [ "isConflicted": false, "number": 1, "sha": "some-head-sha", + "sourceBranch": "some-head-branch", "sourceRepo": "some/repo", "state": "open", "targetBranch": "some-base-branch", @@ -133,7 +133,6 @@ Array [ }, Object { "body": "other random pull request", - "branchName": "other-head-branch", "canMerge": true, "createdAt": "2011-08-18T22:30:38Z", "displayNumber": "Pull Request #2", @@ -141,6 +140,7 @@ Array [ "isConflicted": false, "number": 2, "sha": "other-head-sha", + "sourceBranch": "other-head-branch", "sourceRepo": "some/repo", "state": "closed", "targetBranch": "other-base-branch", diff --git a/lib/platform/gitea/index.spec.ts b/lib/platform/gitea/index.spec.ts index 20101dd20650b251e57532d14927c26a80cc4627..6741556f879fc0788e5e4410134466367508db0b 100644 --- a/lib/platform/gitea/index.spec.ts +++ b/lib/platform/gitea/index.spec.ts @@ -615,7 +615,7 @@ describe('platform/gitea', () => { await initFakeRepo(); const res = await gitea.findPr({ branchName: mockPR.head.label }); - expect(res).toHaveProperty('branchName', mockPR.head.label); + expect(res).toHaveProperty('sourceBranch', mockPR.head.label); }); it('should find pull request with title', async () => { @@ -627,7 +627,7 @@ describe('platform/gitea', () => { branchName: mockPR.head.label, prTitle: mockPR.title, }); - expect(res).toHaveProperty('branchName', mockPR.head.label); + expect(res).toHaveProperty('sourceBranch', mockPR.head.label); expect(res).toHaveProperty('title', mockPR.title); }); @@ -640,7 +640,7 @@ describe('platform/gitea', () => { branchName: mockPR.head.label, state: mockPR.state, }); - expect(res).toHaveProperty('branchName', mockPR.head.label); + expect(res).toHaveProperty('sourceBranch', mockPR.head.label); expect(res).toHaveProperty('state', mockPR.state); }); @@ -667,7 +667,7 @@ describe('platform/gitea', () => { prTitle: mockPR.title, state: mockPR.state, }); - expect(res).toHaveProperty('branchName', mockPR.head.label); + expect(res).toHaveProperty('sourceBranch', mockPR.head.label); expect(res).toHaveProperty('title', mockPR.title); expect(res).toHaveProperty('state', mockPR.state); }); @@ -708,7 +708,7 @@ describe('platform/gitea', () => { await initFakeRepo(); const res = await gitea.createPr({ - branchName: mockNewPR.head.label, + sourceBranch: mockNewPR.head.label, targetBranch: 'devel', prTitle: mockNewPR.title, prBody: mockNewPR.body, @@ -732,7 +732,7 @@ describe('platform/gitea', () => { await initFakeRepo(); const res = await gitea.createPr({ - branchName: mockNewPR.head.label, + sourceBranch: mockNewPR.head.label, targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, @@ -760,7 +760,7 @@ describe('platform/gitea', () => { await initFakeRepo(); await gitea.createPr({ - branchName: mockNewPR.head.label, + sourceBranch: mockNewPR.head.label, targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, @@ -784,7 +784,7 @@ describe('platform/gitea', () => { await initFakeRepo(); await gitea.getPrList(); await gitea.createPr({ - branchName: mockNewPR.head.label, + sourceBranch: mockNewPR.head.label, targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, @@ -801,7 +801,7 @@ describe('platform/gitea', () => { await initFakeRepo(); const res = await gitea.createPr({ - branchName: mockNewPR.head.label, + sourceBranch: mockNewPR.head.label, targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, @@ -816,7 +816,7 @@ describe('platform/gitea', () => { await initFakeRepo(); const res = await gitea.createPr({ - branchName: mockNewPR.head.label, + sourceBranch: mockNewPR.head.label, targetBranch: 'master', prTitle: 'new-title', prBody: 'new-body', @@ -837,7 +837,7 @@ describe('platform/gitea', () => { await initFakeRepo(); await expect( gitea.createPr({ - branchName: mockNewPR.head.label, + sourceBranch: mockNewPR.head.label, targetBranch: 'master', prTitle: mockNewPR.title, prBody: mockNewPR.body, diff --git a/lib/platform/gitea/index.ts b/lib/platform/gitea/index.ts index 80d4f6733b487edc0ab5506b88af0193ac3dfcd3..697183e17cd661a36a7d2d3c8402a643715e46e0 100644 --- a/lib/platform/gitea/index.ts +++ b/lib/platform/gitea/index.ts @@ -98,7 +98,7 @@ function toRenovatePR(data: helper.PR): Pr | null { title: data.title, body: data.body, sha: data.head.sha, - branchName: data.head.label, + sourceBranch: data.head.label, targetBranch: data.base.ref, sourceRepo: data.head.repo.full_name, createdAt: data.created_at, @@ -467,7 +467,7 @@ const platform: Platform = { const pr = prList.find( (p) => p.sourceRepo === config.repository && - p.branchName === branchName && + p.sourceBranch === branchName && matchesState(p.state, state) && (!title || p.title === title) ); @@ -479,14 +479,14 @@ const platform: Platform = { }, async createPr({ - branchName, + sourceBranch, targetBranch, prTitle: title, prBody: rawBody, labels: labelNames, }: CreatePRConfig): Promise<Pr> { const base = targetBranch; - const head = branchName; + const head = sourceBranch; const body = sanitize(rawBody); logger.debug(`Creating pull request: ${title} (${head} => ${base})`); @@ -518,13 +518,13 @@ const platform: Platform = { // would cause a HTTP 409 conflict error, which we hereby gracefully handle. if (err.statusCode === 409) { logger.warn( - `Attempting to gracefully recover from 409 Conflict response in createPr(${title}, ${branchName})` + `Attempting to gracefully recover from 409 Conflict response in createPr(${title}, ${sourceBranch})` ); // Refresh cached PR list and search for pull request with matching information config.prList = null; const pr = await platform.findPr({ - branchName, + branchName: sourceBranch, state: PrState.Open, }); @@ -532,7 +532,7 @@ const platform: Platform = { if (pr) { if (pr.title !== title || pr.body !== body) { logger.debug( - `Recovered from 409 Conflict, but PR for ${branchName} is outdated. Updating...` + `Recovered from 409 Conflict, but PR for ${sourceBranch} is outdated. Updating...` ); await platform.updatePr({ number: pr.number, @@ -543,7 +543,7 @@ const platform: Platform = { pr.body = body; } else { logger.debug( - `Recovered from 409 Conflict and PR for ${branchName} is up-to-date` + `Recovered from 409 Conflict and PR for ${sourceBranch} is up-to-date` ); } diff --git a/lib/platform/github/__snapshots__/index.spec.ts.snap b/lib/platform/github/__snapshots__/index.spec.ts.snap index 62ceb6e3d44ed5f2a991c66ff6a05070c3acf501..16e5a208f8caf0e6494cc4c034b0b34514341fe5 100644 --- a/lib/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/platform/github/__snapshots__/index.spec.ts.snap @@ -110,9 +110,9 @@ Array [ exports[`platform/github createPr() should create a draftPR if set in the settings 1`] = ` Object { - "branchName": "some-branch", "displayNumber": "Pull Request #123", "number": 123, + "sourceBranch": "some-branch", } `; @@ -172,9 +172,9 @@ Array [ exports[`platform/github createPr() should create and return a PR object 1`] = ` Object { - "branchName": "some-branch", "displayNumber": "Pull Request #123", "number": 123, + "sourceBranch": "some-branch", } `; @@ -248,9 +248,9 @@ Array [ exports[`platform/github createPr() should use defaultBranch 1`] = ` Object { - "branchName": "some-branch", "displayNumber": "Pull Request #123", "number": 123, + "sourceBranch": "some-branch", } `; @@ -1884,7 +1884,6 @@ Object { "base": Object { "sha": "1234", }, - "branchName": "somebranch", "canMerge": false, "canMergeReason": "mergeable = undefined", "commits": 1, @@ -1898,6 +1897,7 @@ Object { }, "number": 91, "sha": undefined, + "sourceBranch": "somebranch", "state": "open", } `; @@ -2098,7 +2098,6 @@ Object { "base": Object { "sha": "1234", }, - "branchName": "somebranch", "canMerge": false, "canMergeReason": "mergeable = undefined", "commits": 1, @@ -2112,6 +2111,7 @@ Object { }, "number": 90, "sha": undefined, + "sourceBranch": "somebranch", "state": "open", } `; @@ -2899,7 +2899,6 @@ Array [ exports[`platform/github getPr(prNo) should return PR from closed graphql result 1`] = ` Object { "body": "dummy body", - "branchName": "renovate/delay-4.x", "comments": Array [ Object { "body": ":tada: This PR is included in version 13.63.5 :tada: @@ -2914,6 +2913,7 @@ Your **[semantic-release](https://github.com/semantic-release/semantic-release)* ], "displayNumber": "Pull Request #2499", "number": 2499, + "sourceBranch": "renovate/delay-4.x", "state": "merged", "title": "build(deps): update dependency delay to v4.0.1", } @@ -3089,7 +3089,6 @@ Array [ exports[`platform/github getPr(prNo) should return PR from graphql result 1`] = ` Object { - "branchName": "renovate/jest-monorepo", "canMerge": false, "canMergeReason": "mergeStateStatus = DIRTY", "displayNumber": "Pull Request #2500", @@ -3097,6 +3096,7 @@ Object { "hasReviewers": false, "isConflicted": true, "number": 2500, + "sourceBranch": "renovate/jest-monorepo", "state": "open", "targetBranch": "master", "title": "chore(deps): update dependency jest to v23.6.0", @@ -3425,7 +3425,6 @@ Object { "base": Object { "sha": "1234", }, - "branchName": undefined, "canMerge": false, "canMergeReason": "mergeable = undefined", "commits": 1, @@ -3434,6 +3433,7 @@ Object { "mergeable_state": "dirty", "number": 1, "sha": undefined, + "sourceBranch": undefined, "state": "open", } `; @@ -3622,13 +3622,13 @@ Object { "base": Object { "sha": "5678", }, - "branchName": undefined, "canMerge": true, "commits": 1, "displayNumber": "Pull Request #1", "mergeable": true, "number": 1, "sha": undefined, + "sourceBranch": undefined, "state": "open", } `; diff --git a/lib/platform/github/index.spec.ts b/lib/platform/github/index.spec.ts index 2aacadf589f9123d254665e7a965654ba0a02290..c23fade4c45164b1fe29015cbab70882e5aa3b10 100644 --- a/lib/platform/github/index.spec.ts +++ b/lib/platform/github/index.spec.ts @@ -1603,7 +1603,7 @@ describe('platform/github', () => { .reply(200, []); await github.initRepo({ repository: 'some/repo', token: 'token' } as any); const pr = await github.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'dev', prTitle: 'The Title', prBody: 'Hello world', @@ -1620,7 +1620,7 @@ describe('platform/github', () => { }); await github.initRepo({ repository: 'some/repo', token: 'token' } as any); const pr = await github.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'master', prTitle: 'The Title', prBody: 'Hello world', @@ -1637,7 +1637,7 @@ describe('platform/github', () => { }); await github.initRepo({ repository: 'some/repo', token: 'token' } as any); const pr = await github.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'master', prTitle: 'PR draft', prBody: 'This is a result of a draft', diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 7ce2b2630c002b56a92455b8fc9503890a0f843e..2eb257ea373caaa4ae9bf83b985c38826a74cc66 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -484,7 +484,7 @@ async function getClosedPrs(): Promise<PrList> { // https://developer.github.com/v4/object/pullrequest/ pr.displayNumber = `Pull Request #${pr.number}`; pr.state = pr.state.toLowerCase(); - pr.branchName = pr.headRefName; + pr.sourceBranch = pr.headRefName; delete pr.headRefName; pr.comments = pr.comments.nodes.map((comment) => ({ id: comment.databaseId, @@ -587,7 +587,7 @@ async function getOpenPrs(): Promise<PrList> { // https://developer.github.com/v4/object/pullrequest/ pr.displayNumber = `Pull Request #${pr.number}`; pr.state = PrState.Open; - pr.branchName = pr.headRefName; + pr.sourceBranch = pr.headRefName; delete pr.headRefName; pr.targetBranch = pr.baseRefName; delete pr.baseRefName; @@ -664,7 +664,7 @@ export async function getPr(prNo: number): Promise<Pr | null> { // Harmonise PR values pr.displayNumber = `Pull Request #${pr.number}`; if (pr.state === PrState.Open) { - pr.branchName = pr.head ? pr.head.ref : undefined; + pr.sourceBranch = pr.head ? pr.head.ref : undefined; pr.sha = pr.head ? pr.head.sha : undefined; if (pr.mergeable === true) { pr.canMerge = true; @@ -718,7 +718,7 @@ export async function getPrList(): Promise<Pr[]> { (pr) => ({ number: pr.number, - branchName: pr.head.ref, + sourceBranch: pr.head.ref, sha: pr.head.sha, title: pr.title, state: @@ -744,7 +744,7 @@ export async function findPr({ const prList = await getPrList(); const pr = prList.find( (p) => - p.branchName === branchName && + p.sourceBranch === branchName && (!prTitle || p.title === prTitle) && matchesState(p.state, state) && (config.forkMode || config.repository === p.sourceRepo) // #5188 @@ -1362,7 +1362,7 @@ export async function ensureCommentRemoval({ // Creates PR and returns PR number export async function createPr({ - branchName, + sourceBranch, targetBranch, prTitle: title, prBody: rawBody, @@ -1372,7 +1372,7 @@ export async function createPr({ const body = sanitize(rawBody); const base = targetBranch; // Include the repository owner to handle forkMode and regular mode - const head = `${config.repository.split('/')[0]}:${branchName}`; + const head = `${config.repository.split('/')[0]}:${sourceBranch}`; const options: any = { body: { title, @@ -1395,7 +1395,7 @@ export async function createPr({ ) ).body; logger.debug( - { branch: branchName, pr: pr.number, draft: draftPR }, + { branch: sourceBranch, pr: pr.number, draft: draftPR }, 'PR created' ); // istanbul ignore if @@ -1403,7 +1403,7 @@ export async function createPr({ config.prList.push(pr); } pr.displayNumber = `Pull Request #${pr.number}`; - pr.branchName = branchName; + pr.sourceBranch = sourceBranch; await addLabels(pr.number, labels); return pr; } diff --git a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap index 35ceb8d874a802ff7146bee2af9bc083804ec5f0..0b7fe1bd31844ff4469c1c577f6dc19d482e2f90 100644 --- a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap +++ b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap @@ -200,11 +200,11 @@ Array [ exports[`platform/gitlab createPr(branchName, title, body) returns the PR 1`] = ` Object { - "branchName": "some-branch", "displayNumber": "Merge Request #12345", "id": 1, "iid": 12345, "number": 12345, + "sourceBranch": "some-branch", } `; @@ -229,11 +229,11 @@ Array [ exports[`platform/gitlab createPr(branchName, title, body) uses default branch 1`] = ` Object { - "branchName": "some-branch", "displayNumber": "Merge Request #12345", "id": 1, "iid": 12345, "number": 12345, + "sourceBranch": "some-branch", } `; @@ -767,7 +767,6 @@ Object { "sha": "1234", }, "body": undefined, - "branchName": "some-branch", "commits": 1, "deletions": 1, "displayNumber": "Merge Request #91", @@ -775,6 +774,7 @@ Object { "hasReviewers": false, "iid": 91, "number": 91, + "sourceBranch": "some-branch", "source_branch": "some-branch", "state": "open", "targetBranch": "master", @@ -1093,7 +1093,6 @@ Array [ exports[`platform/gitlab getPr(prNo) returns the PR 1`] = ` Object { "body": "a merge request", - "branchName": "some-branch", "canMerge": false, "description": "a merge request", "displayNumber": "Merge Request #12345", @@ -1105,6 +1104,7 @@ Object { "isConflicted": true, "merge_status": "cannot_be_merged", "number": 12345, + "sourceBranch": "some-branch", "source_branch": "some-branch", "state": "merged", "targetBranch": "master", @@ -1131,7 +1131,6 @@ Array [ exports[`platform/gitlab getPr(prNo) returns the PR with nonexisting branch 1`] = ` Object { "body": "a merge request", - "branchName": "some-branch", "canMerge": false, "description": "a merge request", "displayNumber": "Merge Request #12345", @@ -1143,6 +1142,7 @@ Object { "isConflicted": true, "merge_status": "cannot_be_merged", "number": 12345, + "sourceBranch": "some-branch", "source_branch": "some-branch", "state": "open", "targetBranch": "master", @@ -1169,7 +1169,6 @@ Array [ exports[`platform/gitlab getPr(prNo) returns the mergeable PR 1`] = ` Object { "body": "a merge request", - "branchName": "some-branch", "canMerge": true, "description": "a merge request", "displayNumber": "Merge Request #12345", @@ -1179,6 +1178,7 @@ Object { "id": 1, "iid": 12345, "number": 12345, + "sourceBranch": "some-branch", "source_branch": "some-branch", "state": "open", "targetBranch": "master", diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index b5bc54e26c53a01554758b308c15b23df6f0f4f9..0ceea9a67ceb348756d7afd1fde378ef263d44b4 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -927,7 +927,7 @@ describe('platform/gitlab', () => { iid: 12345, }); const pr = await gitlab.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'master', prTitle: 'some-title', prBody: 'the-body', @@ -945,7 +945,7 @@ describe('platform/gitlab', () => { iid: 12345, }); const pr = await gitlab.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'master', prTitle: 'some-title', prBody: 'the-body', @@ -977,7 +977,7 @@ describe('platform/gitlab', () => { .put('/api/v4/projects/undefined/merge_requests/12345/merge') .reply(200); await gitlab.createPr({ - branchName: 'some-branch', + sourceBranch: 'some-branch', targetBranch: 'master', prTitle: 'some-title', prBody: 'the-body', diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index fa7ea6736ae3a108861688258584b38e0ad8ec6b..662cf95a52cc6062ed0319162fb99d7319233c31 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -337,7 +337,7 @@ export async function getBranchStatus( // Pull Request export async function createPr({ - branchName, + sourceBranch, targetBranch, prTitle: title, prBody: rawDescription, @@ -350,7 +350,7 @@ export async function createPr({ `projects/${config.repository}/merge_requests`, { body: { - source_branch: branchName, + source_branch: sourceBranch, target_branch: targetBranch, remove_source_branch: true, title, @@ -361,7 +361,7 @@ export async function createPr({ ); const pr = res.body; pr.number = pr.iid; - pr.branchName = branchName; + pr.sourceBranch = sourceBranch; pr.displayNumber = `Merge Request #${pr.iid}`; // istanbul ignore if if (config.prList) { @@ -420,7 +420,7 @@ export async function getPr(iid: number): Promise<Pr> { >(url) ).body; // Harmonize fields with GitHub - pr.branchName = pr.source_branch; + pr.sourceBranch = pr.source_branch; pr.targetBranch = pr.target_branch; pr.number = pr.iid; pr.displayNumber = `Merge Request #${pr.iid}`; @@ -435,7 +435,7 @@ export async function getPr(iid: number): Promise<Pr> { pr.canMerge = false; pr.isConflicted = true; } else if (pr.state === PrState.Open) { - const branchStatus = await getBranchStatus(pr.branchName, []); + const branchStatus = await getBranchStatus(pr.sourceBranch, []); if (branchStatus === BranchStatus.green) { pr.canMerge = true; } @@ -913,7 +913,7 @@ async function fetchPrList(): Promise<Pr[]> { >(urlString, { paginate: true }); return res.body.map((pr) => ({ number: pr.iid, - branchName: pr.source_branch, + sourceBranch: pr.source_branch, title: pr.title, state: pr.state === 'opened' ? PrState.Open : pr.state, createdAt: pr.created_at, @@ -952,8 +952,8 @@ export async function findPr({ logger.debug(`findPr(${branchName}, ${prTitle}, ${state})`); const prList = await getPrList(); return prList.find( - (p: { branchName: string; title: string; state: string }) => - p.branchName === branchName && + (p: { sourceBranch: string; title: string; state: string }) => + p.sourceBranch === branchName && (!prTitle || p.title === prTitle) && matchesState(p.state, state) ); diff --git a/lib/workers/branch/reuse.spec.ts b/lib/workers/branch/reuse.spec.ts index f9b77d45c5b6e21007cbbb5d9e94ce39fea26a9c..9c66d53ab9b3012bd54968be56ca549f8e629ae6 100644 --- a/lib/workers/branch/reuse.spec.ts +++ b/lib/workers/branch/reuse.spec.ts @@ -9,7 +9,7 @@ jest.mock('../../util/git'); describe('workers/branch/parent', () => { describe('getParentBranch(config)', () => { const pr: Pr = { - branchName: 'master', + sourceBranch: 'master', state: PrState.Open, title: 'any', }; diff --git a/lib/workers/pr/__snapshots__/index.spec.ts.snap b/lib/workers/pr/__snapshots__/index.spec.ts.snap index fbad3c387588a487aed1dada26a1b0eac0c896c4..5ad42613bd79e926fb4bde9176597bac5624a009 100644 --- a/lib/workers/pr/__snapshots__/index.spec.ts.snap +++ b/lib/workers/pr/__snapshots__/index.spec.ts.snap @@ -41,7 +41,6 @@ Array [ exports[`workers/pr ensurePr should add note about Pin 1`] = ` Array [ Object { - "branchName": "renovate/dummy-1.x", "draftPR": false, "labels": Array [], "platformOptions": Object { @@ -52,6 +51,7 @@ Array [ }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | pin | \`1.0.0\` -> \`1.1.0\` |\\n\\n:pushpin: **Important**: Renovate will wait until you have merged this Pin PR before creating any *upgrade* PRs for the affected packages. Add the preset \`:preserveSemverRanges\` to your config if you instead don't wish to pin dependencies.\\n\\n---\\n\\n### Release Notes\\n\\n<details>\\n<summary>renovateapp/dummy</summary>\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n</details>\\n\\n---\\n\\n### Renovate configuration\\n\\n:date: **Schedule**: \\"before 5am\\" in timezone some timezone.\\n\\n:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\n:recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.\\n\\n:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", + "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, }, ] @@ -73,7 +73,6 @@ Array [ exports[`workers/pr ensurePr should create PR if success 1`] = ` Array [ Object { - "branchName": "renovate/dummy-1.x", "draftPR": false, "labels": Array [], "platformOptions": Object { @@ -84,6 +83,7 @@ Array [ }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n<details>\\n<summary>renovateapp/dummy</summary>\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n</details>\\n\\n---\\n\\n### Renovate configuration\\n\\n:date: **Schedule**: \\"before 5am\\" (UTC).\\n\\n:vertical_traffic_light: **Automerge**: Enabled.\\n\\n:recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\n:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", + "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, }, ] @@ -92,7 +92,6 @@ Array [ exports[`workers/pr ensurePr should create PR if success for gitlab deps 1`] = ` Array [ Object { - "branchName": "renovate/gitlabdummy-1.x", "draftPR": false, "labels": Array [], "platformOptions": Object { @@ -103,6 +102,7 @@ Array [ }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [gitlabdummy](https://dummy.com) ([source](https://gitlab.com/renovateapp/gitlabdummy), [changelog](https://gitlab.com/renovateapp/gitlabdummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Renovate configuration\\n\\n:date: **Schedule**: \\"before 5am\\" (UTC).\\n\\n:vertical_traffic_light: **Automerge**: Enabled.\\n\\n:recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\n:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", + "sourceBranch": "renovate/gitlabdummy-1.x", "targetBranch": undefined, }, ] @@ -111,7 +111,6 @@ Array [ exports[`workers/pr ensurePr should create group PR 1`] = ` Array [ Object { - "branchName": "renovate/dummy-1.x", "draftPR": false, "labels": Array [], "platformOptions": Object { @@ -122,6 +121,7 @@ Array [ }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | lockFileMaintenance | \`1.0.0\` -> \`1.1.0\` |\\n| a | | | \`zzzzzz\` -> \`aaaaaaa\` |\\n| b | | pin | \`some_old_value\` -> \`some_new_value\` |\\n| c | | | \`\` -> \`\` |\\n| d | | lockFileMaintenance | \`\` -> \`\` |\\n\\nnote 1\\n\\nnote 2\\n\\n:warning: Release Notes retrieval for this PR were skipped because no github.com credentials were available.\\nIf you are using the hosted GitLab app, please follow [this guide](https://docs.renovatebot.com/install-gitlab-app/#configuring-a-token-for-githubcom-hosted-release-notes). If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/self-hosting.md#githubcom-token-for-release-notes) instead.\\n\\n:abcd: If you wish to disable git hash updates, add \`\\":disableDigestUpdates\\"\` to the extends array in your config.\\n\\n:wrench: This Pull Request updates lock files to use the latest dependency versions.\\n\\n---\\n\\n### Release Notes\\n\\n<details>\\n<summary>renovateapp/dummy</summary>\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n</details>\\n\\n<details>\\n<summary>renovateapp/dummy</summary>\\n\\n</details>\\n\\n---\\n\\n### Renovate configuration\\n\\n:date: **Schedule**: At any time (no schedule defined).\\n\\n:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\n:recycle: **Rebasing**: Never, or you tick the rebase/retry checkbox.\\n\\n:ghost: **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/config-help/issues) if that's undesired.\\n\\n---\\n\\n - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", + "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, }, ] @@ -130,7 +130,6 @@ Array [ exports[`workers/pr ensurePr should create privateRepo PR if success 1`] = ` Array [ Object { - "branchName": "renovate/dummy-1.x", "draftPR": false, "labels": Array [], "platformOptions": Object { @@ -141,6 +140,7 @@ Array [ }, "prBody": "This PR contains the following updates:\\n\\n| Package | Type | Update | Change |\\n|---|---|---|---|\\n| [dummy](https://dummy.com) ([source](https://github.com/renovateapp/dummy), [changelog](https://github.com/renovateapp/dummy/changelog.md)) | devDependencies | minor | \`1.0.0\` -> \`1.1.0\` |\\n\\n---\\n\\n### Release Notes\\n\\n<details>\\n<summary>someproject</summary>\\n\\n### [\`v1.1.0\`](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n[Compare Source](https://github.com/renovateapp/dummy/compare/v1.0.0...v1.1.0)\\n\\n</details>\\n\\n---\\n\\n### Renovate configuration\\n\\n:date: **Schedule**: At any time (no schedule defined).\\n\\n:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\\n\\n:recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.\\n\\n:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.\\n\\n---\\n\\n - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box\\n\\n---\\n\\nThis PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).", "prTitle": "Update dependency dummy to v1.1.0", + "sourceBranch": "renovate/dummy-1.x", "targetBranch": undefined, }, ] diff --git a/lib/workers/pr/code-owners.ts b/lib/workers/pr/code-owners.ts index 21930d3104f70b3b72f4fd321829c98c9d60b8b7..c6efc89d9a1a125646966c8494cdad712eb787bb 100644 --- a/lib/workers/pr/code-owners.ts +++ b/lib/workers/pr/code-owners.ts @@ -16,7 +16,7 @@ export async function codeOwnersForPr(pr: Pr): Promise<string[]> { return []; } - const prFiles = await getBranchFiles(pr.branchName); + const prFiles = await getBranchFiles(pr.sourceBranch); const rules = codeOwnersFile .split('\n') .map((line) => line.trim()) diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts index 6116a38b1fe59f58071221d926705951f6af1b09..3030ed65013f4ea079cfeb5493923a5a6b8f9d11 100644 --- a/lib/workers/pr/index.ts +++ b/lib/workers/pr/index.ts @@ -367,7 +367,7 @@ export async function ensurePr( return { prResult: PrResult.LimitReached }; } pr = await platform.createPr({ - branchName, + sourceBranch: branchName, targetBranch: config.baseBranch, prTitle, prBody, diff --git a/lib/workers/repository/onboarding/branch/index.spec.ts b/lib/workers/repository/onboarding/branch/index.spec.ts index f4be1d9bfc1c452fac7a462c312081cfdf8dc1a9..7b7a25482c8e98f768c36d0b6604a17c02626bca 100644 --- a/lib/workers/repository/onboarding/branch/index.spec.ts +++ b/lib/workers/repository/onboarding/branch/index.spec.ts @@ -84,7 +84,7 @@ describe('workers/repository/onboarding/branch', () => { platform.getPrList.mockResolvedValueOnce([ { ...mock<Pr>(), - branchName: 'renovate/something', + sourceBranch: 'renovate/something', state: PrState.Open, }, ]); diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index 2ec8b74d47f8722d6363ebd0427281a912fb30fd..b0626f8c4c1f27316837aa8aefe7c309b9237649 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -132,7 +132,7 @@ If you need any further assistance then you can also [request help here](${confi logger.info('DRY-RUN: Would create onboarding PR'); } else { const pr = await platform.createPr({ - branchName: config.onboardingBranch, + sourceBranch: config.onboardingBranch, targetBranch: config.defaultBranch, prTitle: config.onboardingPrTitle, prBody, diff --git a/lib/workers/repository/process/limits.spec.ts b/lib/workers/repository/process/limits.spec.ts index 5dfbb4eae2a7b6698a18668d604fb9ccd9bdb010..8c2fc901ec3738ad17841a7a30ea133f9f84101f 100644 --- a/lib/workers/repository/process/limits.spec.ts +++ b/lib/workers/repository/process/limits.spec.ts @@ -23,7 +23,7 @@ describe('workers/repository/process/limits', () => { platform.getPrList.mockResolvedValueOnce([ { createdAt: moment().toISOString(), - branchName: null, + sourceBranch: null, title: null, state: null, }, diff --git a/lib/workers/repository/process/limits.ts b/lib/workers/repository/process/limits.ts index ee0066d6697bccc2851cafa0eb0808ca3d0aaf42..d26b5391cf76c27e1bfd80d85a659d1250df776a 100644 --- a/lib/workers/repository/process/limits.ts +++ b/lib/workers/repository/process/limits.ts @@ -18,7 +18,7 @@ export async function getPrHourlyRemaining( try { const soFarThisHour = prList.filter( (pr) => - pr.branchName !== config.onboardingBranch && + pr.sourceBranch !== config.onboardingBranch && moment(pr.createdAt).isAfter(currentHourStart) ); const prsRemaining = config.prHourlyLimit - soFarThisHour.length;