diff --git a/lib/workers/pr/index.js b/lib/workers/pr/index.js index 6be25df16d1fe620e74bbaa3601ad0c2ed17cb8d..bf279d68c0427cd20cda59c9a60795fe6f5f215d 100644 --- a/lib/workers/pr/index.js +++ b/lib/workers/pr/index.js @@ -170,6 +170,25 @@ async function ensurePr(prConfig) { return existingPr; } // PR must need updating + if (existingPr.title !== prTitle) { + logger.debug( + { + oldPrTitle: existingPr.title, + newPrTitle: prTitle, + }, + 'PR title changed' + ); + } else { + logger.debug( + { + prTitle, + oldPrBody: existingPr.body, + newPrBody: prBody, + }, + 'PR body changed' + ); + } + await platform.updatePr(existingPr.number, prTitle, prBody); logger.info({ pr: existingPr.displayNumber }, `Updated PR`); return existingPr; diff --git a/test/workers/pr/__snapshots__/index.spec.js.snap b/test/workers/pr/__snapshots__/index.spec.js.snap index 9695c5f1364a44ce263aedaba914d40d3e0137fd..0cb5828da5323f279860f24c189b89fb8853fa04 100644 --- a/test/workers/pr/__snapshots__/index.spec.js.snap +++ b/test/workers/pr/__snapshots__/index.spec.js.snap @@ -102,6 +102,32 @@ This PR has been generated by [Renovate Bot](https://renovateapp.com).", } `; +exports[`workers/pr ensurePr should return modified existing PR title 1`] = ` +Object { + "body": "This Pull Request updates dependency [dummy](https://github.com/renovateapp/dummy) from \`v1.0.0\` to \`v1.1.0\` + + + +### Commits + +<details> +<summary>renovateapp/dummy</summary> + +#### 1.1.0 +- [\`abcdefg\`](https://github.com/renovateapp/dummy/commit/abcdefghijklmnopqrstuvwxyz) foo [#3](https://github.com/renovateapp/dummy/issues/3) + +</details> + + + +--- + +This PR has been generated by [Renovate Bot](https://renovateapp.com).", + "displayNumber": "Existing PR", + "title": "wrong", +} +`; + exports[`workers/pr ensurePr should return unmodified existing PR 1`] = `Array []`; exports[`workers/pr ensurePr should strip HTML PR for vsts 1`] = ` diff --git a/test/workers/pr/index.spec.js b/test/workers/pr/index.spec.js index 231a56e37cfd111a2e1ea9117adcb281b3e329fa..583d246c0e6dd64b521f3827e8966265c072409c 100644 --- a/test/workers/pr/index.spec.js +++ b/test/workers/pr/index.spec.js @@ -272,6 +272,15 @@ describe('workers/pr', () => { const pr = await prWorker.ensurePr(config); expect(pr).toMatchSnapshot(); }); + it('should return modified existing PR title', async () => { + config.newVersion = '1.2.0'; + platform.getBranchPr.mockReturnValueOnce({ + ...existingPr, + title: 'wrong', + }); + const pr = await prWorker.ensurePr(config); + expect(pr).toMatchSnapshot(); + }); it('should create PR if branch tests failed', async () => { config.automerge = true; config.automergeType = 'branch-push';