Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So
package-lock.json
gets conflicted often enough and this can be a pain.The following bit in a
.gitattributes
is used in the appium monorepo:This is fine, except when confronted with a conflict, Git will just punt; I suppose that's better than the default alternative--which is a poor text merge indeed.
But, I know that the way to resolve these conflicts is to run
npm install
. I thought; why not just do that?So this does that -- though it requires a manual step for security reasons.
When Git detects a conflict in
package-lock.json
, it will run thenpm
merge tool--which just runsnpm install
. Ifnpm install
exits with a 0 error code andpackage-lock.json
was modified, Git will markpackage-lock.json
as resolved.If there's also a conflict in
package.json
this will not work, becausenpm install
can't run if yourpackage.json
is in a conflicted state.To enable this, the developer has to run
This modifies
.git/config
and tells it to include.gitconfig
(added). Git will otherwise not recognize the.gitconfig
file and the auto-merge ofpackage-lock.json
will fail, and you'll have to runnpm install
yourself as before.Please try this and see if it's helpful. It might not be.