Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Handle shrinkwrap merge conflicts with merge driver #25599

Merged
merged 1 commit into from
Jun 20, 2018

Conversation

blowery
Copy link
Contributor

@blowery blowery commented Jun 19, 2018

This stops treating npm-shrinkwrap.json as a binary file and instead treats it as a text file with a custom merge driver. See https://www.npmjs.com/package/npm-merge-driver and https://docs.npmjs.com/files/package-locks#resolving-lockfile-conflicts for more details.

To test, find a PR with a merge conflict in npm-shrinkwrap and rebase it locally on top of this PR. The shrinkwrap conflict should be handled automatically.

Currently this is what i used:

git fetch
git checkout update/npm-shrinkwrap-merge-drive
npm ci
git checkout renovate/lunr-0.x
git rebase update/npm-shrinkwrap-merge-drive
# watch npm-merge-driver get used

output should look like

npm-merge-driver: merging npm-shrinkwrap.json

> undefined postshrinkwrap /Users/blowery/src/a8c/wp-calypso
> node -e "fs.utimesSync( './node_modules', new Date(), new Date() );"

npm WARN redux-form@7.0.2 requires a peer of redux@^3.0.0 but none is installed. You must install peer dependencies yourself.

updated 1 package and audited 55774 packages in 13.265s
found 49 vulnerabilities (16 low, 30 moderate, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details
npm-merge-driver: npm-shrinkwrap.json successfully merged.

This stops treating npm-shrinkwrap.json as a binary file and instead treats it as a text file with a custom merge driver. See https://www.npmjs.com/package/npm-merge-driver and https://docs.npmjs.com/files/package-locks\#resolving-lockfile-conflicts for more details.
@matticbot
Copy link
Contributor

@blowery blowery requested a review from a team June 19, 2018 18:22
@blowery blowery added Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jun 19, 2018
@blowery blowery self-assigned this Jun 19, 2018
@blowery blowery changed the title Framework: Handle npm-shrinkwrap merge conflicts with merge driver Framework: Handle shrinkwrap merge conflicts with merge driver Jun 19, 2018
@dmsnell
Copy link
Member

dmsnell commented Jun 20, 2018

https://www.npmjs.com/package/npm-merge-driver

figures. they show "Attempting to auto-merge" but don't mention what happens when a merge fails. Do you know @blowery?

https://docs.npmjs.com/files/package-locks#resolving-lockfile-conflicts

(updated your link by the way because it had an erroneous \ in it)

this seems to suggest that a real conflict is impossible? should we ever get a merge conflict for real after this?

@blowery
Copy link
Contributor Author

blowery commented Jun 20, 2018

this seems to suggest that a real conflict is impossible? should we ever get a merge conflict for real after this?

Correct, the way this handles the "merge" is to run npm install --package-lock-only which generates a fresh lockfile. It's not merging in the typical sense, it's overwriting.

@blowery
Copy link
Contributor Author

blowery commented Jun 20, 2018

they show "Attempting to auto-merge" but don't mention what happens when a merge fails.

It throws an error. It's unclear to me if it may still write out the lockfile.

https://github.com/npm/npm-merge-driver/blob/latest/index.js#L208

@blowery blowery merged commit 6c03919 into master Jun 20, 2018
@blowery blowery deleted the update/npm-shrinkwrap-merge-drive branch June 20, 2018 12:15
@blowery blowery removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants