Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Fails ungracefully if package.json also has a merge conflict #2

Description

@billyjanitsch

If both package.json and package-lock.json have merge conflicts, the merge driver fails ungracefully. Here's what it looks like:

Details
Using index info to reconstruct a base tree...
M	<redacted>/npm-shrinkwrap.json
M	<redacted>/package.json
Falling back to patching base and 3-way merge...
npx: installed 52 in 1.765s
npm-merge-driver: merging <redacted>/npm-shrinkwrap.json
npm ERR! file <redacted>/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected token < in JSON at position 1652 while parsing near '...helpers": "^3.2.1",
npm ERR! <<<<<<< HEAD
npm ERR!     "en...'
npm ERR! File: <redacted>/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR! 
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! A complete log of this run can be found in:
npm ERR!     <redacted>/.npm/_logs/2017-12-19T21_20_36_300Z-debug.log
npm-merge-driver: --legacy enabled. Checking out --theirs and retrying merge.
npm-merge-driver: !!!SOME CHANGES MAY BE LOST!!!
npm ERR! file <redacted>/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected token < in JSON at position 1652 while parsing near '...helpers": "^3.2.1",
npm ERR! <<<<<<< HEAD
npm ERR!     "en...'
npm ERR! File: <redacted>/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR! 
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! A complete log of this run can be found in:
npm ERR!     <redacted>/.npm/_logs/2017-12-19T21_20_38_207Z-debug.log
Command failed: npm install --package-lock-only
Auto-merging <redacted>/package.json
CONFLICT (content): Merge conflict in <redacted>/package.json
Auto-merging <redacted>/npm-shrinkwrap.json
CONFLICT (content): Merge conflict in <redacted>/npm-shrinkwrap.json
error: Failed to merge in the changes.
Patch failed at 0001 FE2: upgrade test tooling
The copy of the patch that failed is found in: .git/rebase-apply/patch

Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

You can repro by doing something like:

git init && npm init -y
npm i enzyme@2 eslint@3
git add . && git commit -m "Initial commit"

git checkout -b enzyme master
npm i enzyme@latest
git add . && git commit -m "Upgrade enzyme"

git checkout -b eslint master
npm i eslint@latest
git add . && git commit -m "Upgrade eslint"

git rebase enzyme

I'm not familiar with git merge drivers. I assume it's impossible to resolve the package.json conflicts automatically, but would it be possible to detect this case and display a more graceful error message explaining what happened and what I need to do next?

P.S. Thank you for making this ❤️

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions