diff --git a/lib/config/definitions.js b/lib/config/definitions.js index db59026f110374927bdef89e0155fda048c15485..64471f66421e573819f42450a59931e73b0a377b 100644 --- a/lib/config/definitions.js +++ b/lib/config/definitions.js @@ -632,7 +632,7 @@ const options = [ { name: 'automergeType', description: - 'How to automerge - "branch-merge-commit", "branch-push", "pr-comment" or "pr". Branch support is GitHub-only', + 'How to automerge - "branch", "pr", or "pr-comment". Branch support is GitHub-only', type: 'string', default: 'pr', }, diff --git a/lib/config/migration.js b/lib/config/migration.js index bcdad02fbbe4944f0f4e8709ae01efc1f036ff4a..fcd16d68b1369585acd06543e96fa3cc0c5e1d8f 100644 --- a/lib/config/migration.js +++ b/lib/config/migration.js @@ -133,6 +133,9 @@ function migrateConfig(config) { migratedConfig.extends[i] = 'config:js-lib'; } } + } else if (key === 'automergeType' && val.startsWith('branch-')) { + isMigrated = true; + migratedConfig.automergeType = 'branch'; } else if (key === 'automergeMinor') { isMigrated = true; migratedConfig.minor = migratedConfig.minor || {}; diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 13a058e561f82534c42ac4b85a2c688d6186b62a..12b62ee73bdb8948df0b30c0b20b5922afe674f0 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -536,7 +536,7 @@ async function mergeBranch(branchName, mergeType) { 'Branch protection: Attempting to merge branch when push protection is enabled' ); } - if (mergeType === 'branch-push') { + if (mergeType === 'branch') { const url = `repos/${config.repository}/git/refs/heads/${ config.baseBranch }`; @@ -552,24 +552,7 @@ async function mergeBranch(branchName, mergeType) { expandError(err), `Error pushing branch merge for ${branchName}` ); - throw new Error('branch-push failed'); - } - } else if (mergeType === 'branch-merge-commit') { - const url = `repos/${config.repository}/merges`; - const options = { - body: { - base: config.baseBranch, - head: branchName, - }, - }; - try { - await get.post(url, options); - } catch (err) { - logger.info( - expandError(err), - `Error pushing branch merge for ${branchName}` - ); - throw new Error('branch-merge-commit failed'); + throw new Error('Branch automerge failed'); } } else { throw new Error(`Unsupported branch merge type: ${mergeType}`); diff --git a/lib/workers/branch/parent.js b/lib/workers/branch/parent.js index 49576973d01287020b60a0a5dc126dc17ab97e88..bbfd86af620a68aaa8407076a91b0b997bc24103 100644 --- a/lib/workers/branch/parent.js +++ b/lib/workers/branch/parent.js @@ -18,7 +18,7 @@ async function getParentBranch(config) { if ( config.rebaseStalePrs || (config.rebaseStalePrs === null && (await platform.getRepoForceRebase())) || - (config.automerge && config.automergeType === 'branch-push') + (config.automerge && config.automergeType === 'branch') ) { const isBranchStale = await platform.isBranchStale(branchName); if (isBranchStale) { diff --git a/test/config/__snapshots__/migration.spec.js.snap b/test/config/__snapshots__/migration.spec.js.snap index f51d5e05993f64c4ce5634b85ec3d5e5da96fe8b..e4abe7bac76f9d4b49490922c86cd1895de29ea3 100644 --- a/test/config/__snapshots__/migration.spec.js.snap +++ b/test/config/__snapshots__/migration.spec.js.snap @@ -10,6 +10,7 @@ exports[`config/migration migrateConfig(config, parentConfig) it migrates config Object { "autodiscover": true, "automerge": false, + "automergeType": "branch", "baseBranches": Array [ "next", ], diff --git a/test/config/migration.spec.js b/test/config/migration.spec.js index cf9213a83f77a93011240f91662d777ea400976f..d30f70a43cd82917353a538dfe3be856e72601ae 100644 --- a/test/config/migration.spec.js +++ b/test/config/migration.spec.js @@ -17,6 +17,7 @@ describe('config/migration', () => { automergeMinor: true, automergePatch: true, upgradeInRange: true, + automergeType: 'branch-push', baseBranch: 'next', ignoreNodeModules: true, node: { diff --git a/test/platform/github/__snapshots__/index.spec.js.snap b/test/platform/github/__snapshots__/index.spec.js.snap index c50ef7cca365b97862a63b0849dbf5cd19b8fd58..4a089e6f3e68711cd90ef3010e84349a0d9c595d 100644 --- a/test/platform/github/__snapshots__/index.spec.js.snap +++ b/test/platform/github/__snapshots__/index.spec.js.snap @@ -686,51 +686,7 @@ Object { } `; -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-merge-commit merge 1`] = ` -Array [ - Array [ - "repos/some/repo", - ], - Array [ - "repos/some/repo/pulls?per_page=100&state=all", - Object { - "paginate": true, - }, - ], - Array [ - "repos/some/repo/git/trees/master?recursive=true", - ], -] -`; - -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-merge-commit merge 2`] = `Array []`; - -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-merge-commit merge 3`] = ` -Array [ - Array [ - "repos/some/repo/merges", - Object { - "body": Object { - "base": "master", - "head": "thebranchname", - }, - }, - ], -] -`; - -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-merge-commit merge 4`] = `Array []`; - -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-merge-commit merge 5`] = ` -Array [ - Array [ - "repos/some/repo/git/refs/heads/thebranchname", - undefined, - ], -] -`; - -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-push merge 1`] = ` +exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch merge 1`] = ` Array [ Array [ "repos/some/repo", @@ -750,7 +706,7 @@ Array [ ] `; -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-push merge 2`] = ` +exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch merge 2`] = ` Array [ Array [ "repos/some/repo/git/refs/heads/master", @@ -763,11 +719,11 @@ Array [ ] `; -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-push merge 3`] = `Array []`; +exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch merge 3`] = `Array []`; -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-push merge 4`] = `Array []`; +exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch merge 4`] = `Array []`; -exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch-push merge 5`] = ` +exports[`platform/github mergeBranch(branchName, mergeType) should perform a branch merge 5`] = ` Array [ Array [ "repos/some/repo/git/refs/heads/thebranchname", @@ -776,48 +732,9 @@ Array [ ] `; -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-merge-commit throws 1`] = `[Error: branch-merge-commit failed]`; - -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-merge-commit throws 2`] = ` -Array [ - Array [ - "repos/some/repo", - ], - Array [ - "repos/some/repo/pulls?per_page=100&state=all", - Object { - "paginate": true, - }, - ], - Array [ - "repos/some/repo/git/trees/master?recursive=true", - ], -] -`; - -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-merge-commit throws 3`] = `Array []`; - -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-merge-commit throws 4`] = ` -Array [ - Array [ - "repos/some/repo/merges", - Object { - "body": Object { - "base": "master", - "head": "thebranchname", - }, - }, - ], -] -`; - -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-merge-commit throws 5`] = `Array []`; - -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-merge-commit throws 6`] = `Array []`; - -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-push merge throws 1`] = `[Error: branch-push failed]`; +exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch merge throws 1`] = `[Error: Branch automerge failed]`; -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-push merge throws 2`] = ` +exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch merge throws 2`] = ` Array [ Array [ "repos/some/repo", @@ -837,7 +754,7 @@ Array [ ] `; -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-push merge throws 3`] = ` +exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch merge throws 3`] = ` Array [ Array [ "repos/some/repo/git/refs/heads/master", @@ -850,11 +767,11 @@ Array [ ] `; -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-push merge throws 4`] = `Array []`; +exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch merge throws 4`] = `Array []`; -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-push merge throws 5`] = `Array []`; +exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch merge throws 5`] = `Array []`; -exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch-push merge throws 6`] = `Array []`; +exports[`platform/github mergeBranch(branchName, mergeType) should throw if branch merge throws 6`] = `Array []`; exports[`platform/github mergeBranch(branchName, mergeType) should throw if unknown merge type 1`] = `[Error: Unsupported branch merge type: wrong-merge-type]`; diff --git a/test/platform/github/index.spec.js b/test/platform/github/index.spec.js index cc081c9551126bbfc57ece829ba164d168c49aaf..d7a51c78f99c4e15c82eb8c1591e27a00dc89ce0 100644 --- a/test/platform/github/index.spec.js +++ b/test/platform/github/index.spec.js @@ -831,7 +831,7 @@ describe('platform/github', () => { }); }); describe('mergeBranch(branchName, mergeType)', () => { - it('should perform a branch-push merge', async () => { + it('should perform a branch merge', async () => { await initRepo({ repository: 'some/repo', token: 'token', @@ -854,14 +854,14 @@ describe('platform/github', () => { })); // deleteBranch get.delete.mockImplementationOnce(); - await github.mergeBranch('thebranchname', 'branch-push'); + await github.mergeBranch('thebranchname', 'branch'); expect(get.mock.calls).toMatchSnapshot(); expect(get.patch.mock.calls).toMatchSnapshot(); expect(get.post.mock.calls).toMatchSnapshot(); expect(get.put.mock.calls).toMatchSnapshot(); expect(get.delete.mock.calls).toMatchSnapshot(); }); - it('should throw if branch-push merge throws', async () => { + it('should throw if branch merge throws', async () => { await initRepo({ repository: 'some/repo', token: 'token', @@ -874,51 +874,11 @@ describe('platform/github', () => { }, })); get.patch.mockImplementationOnce(() => { - throw new Error('branch-push failed'); + throw new Error('branch failed'); }); let e; try { - await github.mergeBranch('thebranchname', 'branch-push'); - } catch (err) { - e = err; - } - expect(e).toMatchSnapshot(); - expect(get.mock.calls).toMatchSnapshot(); - expect(get.patch.mock.calls).toMatchSnapshot(); - expect(get.post.mock.calls).toMatchSnapshot(); - expect(get.put.mock.calls).toMatchSnapshot(); - expect(get.delete.mock.calls).toMatchSnapshot(); - }); - it('should perform a branch-merge-commit merge', async () => { - await initRepo({ - repository: 'some/repo', - token: 'token', - }); // getBranchCommit - get.mockImplementationOnce(() => ({ - body: { - object: { - sha: '1235', - }, - }, - })); - await github.mergeBranch('thebranchname', 'branch-merge-commit'); - expect(get.mock.calls).toMatchSnapshot(); - expect(get.patch.mock.calls).toMatchSnapshot(); - expect(get.post.mock.calls).toMatchSnapshot(); - expect(get.put.mock.calls).toMatchSnapshot(); - expect(get.delete.mock.calls).toMatchSnapshot(); - }); - it('should throw if branch-merge-commit throws', async () => { - await initRepo({ - repository: 'some/repo', - token: 'token', - }); - get.post.mockImplementationOnce(() => { - throw new Error('branch-push failed'); - }); - let e; - try { - await github.mergeBranch('thebranchname', 'branch-merge-commit'); + await github.mergeBranch('thebranchname', 'branch'); } catch (err) { e = err; } diff --git a/test/workers/branch/automerge.spec.js b/test/workers/branch/automerge.spec.js index b86c18ef9720724fdcfa872c2c8c749b91deaa10..3fbdd5cd55c0f59efe0e1a3feb4e5153a55aa20a 100644 --- a/test/workers/branch/automerge.spec.js +++ b/test/workers/branch/automerge.spec.js @@ -20,20 +20,20 @@ describe('workers/branch/automerge', () => { }); it('returns false if branch status is not success', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('pending'); expect(await tryBranchAutomerge(config)).toBe('no automerge'); }); it('returns branch status error if branch status is failure', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('failure'); expect(await tryBranchAutomerge(config)).toBe('branch status error'); }); it('returns false if PR exists', async () => { platform.getBranchPr.mockReturnValueOnce({}); config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('success'); expect(await tryBranchAutomerge(config)).toBe( 'automerge aborted - PR exists' @@ -41,7 +41,7 @@ describe('workers/branch/automerge', () => { }); it('returns false if automerge fails', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('success'); platform.mergeBranch.mockImplementationOnce(() => { throw new Error('merge error'); @@ -50,7 +50,7 @@ describe('workers/branch/automerge', () => { }); it('returns true if automerge succeeds', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('success'); expect(await tryBranchAutomerge(config)).toBe('automerged'); }); diff --git a/test/workers/branch/parent.spec.js b/test/workers/branch/parent.spec.js index a86a7743166c63aa6f980637b9c05db8577a82e5..53e3fbeb3378cc39e50a394deb071c942b328756 100644 --- a/test/workers/branch/parent.spec.js +++ b/test/workers/branch/parent.spec.js @@ -59,16 +59,16 @@ describe('workers/branch/parent', () => { expect(res.parentBranch).toBe(undefined); expect(platform.deleteBranch.mock.calls.length).toBe(1); }); - it('returns branchName if automerge branch-push and not stale', async () => { + it('returns branchName if automerge branch and not stale', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.branchExists.mockReturnValue(true); const res = await getParentBranch(config); expect(res.parentBranch).toBe(config.branchName); }); - it('returns undefined if automerge branch-push and stale', async () => { + it('returns undefined if automerge branch and stale', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.branchExists.mockReturnValue(true); platform.isBranchStale.mockReturnValueOnce(true); const res = await getParentBranch(config); diff --git a/test/workers/pr/index.spec.js b/test/workers/pr/index.spec.js index 57af38cc8345c1f193392e5b34241589aa79b85c..12a9459e3c31d1cd1840da0f75933d50f3daffb3 100644 --- a/test/workers/pr/index.spec.js +++ b/test/workers/pr/index.spec.js @@ -299,7 +299,7 @@ describe('workers/pr', () => { }); it('should create PR if branch tests failed', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; config.branchAutomergeFailureMessage = 'branch status error'; platform.getBranchStatus.mockReturnValueOnce('failure'); const pr = await prWorker.ensurePr(config); @@ -307,7 +307,7 @@ describe('workers/pr', () => { }); it('should create PR if branch automerging failed', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('success'); config.forcePr = true; const pr = await prWorker.ensurePr(config); @@ -315,7 +315,7 @@ describe('workers/pr', () => { }); it('should return null if branch automerging not failed', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('pending'); platform.getBranchLastCommitTime.mockReturnValueOnce(new Date()); const pr = await prWorker.ensurePr(config); @@ -323,7 +323,7 @@ describe('workers/pr', () => { }); it('should not return null if branch automerging taking too long', async () => { config.automerge = true; - config.automergeType = 'branch-push'; + config.automergeType = 'branch'; platform.getBranchStatus.mockReturnValueOnce('pending'); platform.getBranchLastCommitTime.mockReturnValueOnce( new Date('2018-01-01') diff --git a/website/docs/configuration-options.md b/website/docs/configuration-options.md index dd86ac41d5f3ebae6c1d8c245a17d1073a62bce2..0137df69816651c340d6d17f07661e6d6fe25b4f 100644 --- a/website/docs/configuration-options.md +++ b/website/docs/configuration-options.md @@ -524,7 +524,7 @@ This feature supports simple caret (`^`) and tilde (`~`) ranges only, like `^1.0 This field is defaulted to `null` because it has a potential to create a lot of noise and additional builds to your repository. If you enable it to true, it means each Renovate branch will be updated whenever the base branch has changed. If enabled, this also means that whenever a Renovate PR is merged (whether by automerge or manually via GitHub web) then any other existing Renovate PRs will then need to get rebased and retested. -If you set it to `false` then that will take precedence - it means Renovate will ignore if you have configured the repository for "Require branches to be up to date before merging" in Branch Protection. However if you have configured it to `false` _and_ configured `branch-push` automerge then Renovate will still rebase as necessary for that. +If you set it to `false` then that will take precedence - it means Renovate will ignore if you have configured the repository for "Require branches to be up to date before merging" in Branch Protection. However if you have configured it to `false` _and_ configured `branch` automerge then Renovate will still rebase as necessary for that. ## recreateClosed diff --git a/website/docs/dependency-pinning.md b/website/docs/dependency-pinning.md index 6a2280d1d282ed9a2159017de1a6579788fe2d67..4235e62deba2b57eecfce25fe721f9fd8889e527 100644 --- a/website/docs/dependency-pinning.md +++ b/website/docs/dependency-pinning.md @@ -71,7 +71,7 @@ Another example of a good candidate for automerging might be a database driver l ##### Branch automerging -In the above suggestion of Pull Request automerging, you might still find it annoying if you receive GitHub Notifications for every PR that is created and merged. In that case, you could set `automergeType` to `branch-push`, which means Renovate will: +In the above suggestion of Pull Request automerging, you might still find it annoying if you receive GitHub Notifications for every PR that is created and merged. In that case, you could set `automergeType` to `branch`, which means Renovate will: - Create a new branch for testing - Wait until after tests have completed diff --git a/website/docs/noise-reduction.md b/website/docs/noise-reduction.md index b7dca7d8911435716aad1b6aaa351c339d94a110..4b8cfa0b1afb2423d5b41fd4d85182cf74192c8a 100644 --- a/website/docs/noise-reduction.md +++ b/website/docs/noise-reduction.md @@ -86,7 +86,7 @@ For example, if you have `jest` or `mocha` as a dependency, and it has an upgrad #### Branch automerging -Those of you familiar with GitHub might note that even if you automerge PRs, you are still going to get notifications (noise) anyway - one when the PR is created and another when it is merged. For this reason we recommend you consider setting `automergeType=branch-push` which will mean: +Those of you familiar with GitHub might note that even if you automerge PRs, you are still going to get notifications (noise) anyway - one when the PR is created and another when it is merged. For this reason we recommend you consider setting `automergeType=branch` which will mean: - Renovate first creates a branch and no PR - If tests pass, Renovate pushes a commit directly to `master` without PR @@ -116,7 +116,7 @@ Remember our running `eslint` example? Let's automerge it if all the linting upd "groupName": "eslint", "schedule": ["before 2am on monday"], "automerge": true, - "automergeType": "branch-push" + "automergeType": "branch" } ] ```