4

We keep getting a conflict for the version field in the package.json. For instance:

"version": "1.1.144"

and:

"version": "1.1.145"

Is there a way to auto-resolve it with the highest version number?

Junji Shimagaki
  • 180
  • 1
  • 9
Guy
  • 9,859
  • 13
  • 63
  • 104
  • How do you manage releases/versions ? What is your [git flow](http://nvie.com/posts/a-successful-git-branching-model/) ? – Gabriel Bleu Mar 20 '18 at 13:27
  • If you always know which one to pick you can use `--ours` or `--theirs` [see](https://stackoverflow.com/questions/161813/how-to-resolve-merge-conflicts-in-git) – Gabriel Bleu Mar 20 '18 at 13:46
  • @GabrielBleu our core project is git flow. The question is regarding one of its dependencies which is a private npm package project. There are several of those. Those npm packages have a gulp build process which bumps the minor version. The merge logic for us should be - always take the bigger version number. It is not always known whether the bigger number is the local or the remote version. – Guy Mar 20 '18 at 16:39

1 Answers1

0

Ended up writing an npm package that checks for the version in the remote and sets the local version to match.

npm install -g node-version-match

and from a project's directory:

level

This will sets the local package.json version to match the remote package.json version:

{
  "name": "package",
  "version": "0.0.152", // <=== sets this to equal the version in remote
 ...

This prevents conflicts before pulling, afterwards we change the version number, commit & push.

Guy
  • 9,859
  • 13
  • 63
  • 104
  • do you have example of how you have used ? what I am looking is similar one to happen in PRs in BitBucket. – sam_dev Nov 27 '20 at 12:52