-
Notifications
You must be signed in to change notification settings - Fork 27
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
Minimal update of lock file #305
Conversation
TDD style Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Note that the documentation page I added is obviously incomplete but I think it's better to improve it iteratively than to wait to have a perfection version of it before merging it. I'm happy to add to it in a separate PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also pleasantly surprised how little changes (at least from the core logic part) it is. Hence I mostly looked at that to suggest some improvements. Glad to see that the implementation matches how my hunch it could be implemented, which is great since that means that the complexity increase of the code is very manageable 👍
The flags & parsing and tests look good. It's a bunch of code but essentially not-exciting code and the compiler does a good job of making sure this checks out.
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
a4f1bf6
to
9d65c0b
Compare
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
9d65c0b
to
4f50022
Compare
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Signed-off-by: Nathan Rebours <nathan.p.rebours@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, let's merge it!
CHANGES: ### Added - Add a `--minimal-update` flag to `lock` to generate a lockfile with minimum dependency changes from a previous lockfile. (tarides/opam-monorepo#305, @NathanReb) - Add command line options to complement or overwrite `x-opam-monorepo-*` fields. (tarides/opam-monorepo#307, @NathanReb) - Save the `lock` CLI arguments in `x-opam-monorepo-cli-args` when generating a lock file. (tarides/opam-monorepo#309, @NathanReb)
This PR adds a
--minimal-update
flag tolock
which allows for updating the lock file, aiming at minimum changes in the dependencies.When the flag is passed, the target lockfile (i.e. the one that it will write the generated lock file to) must already exists. It parsed and the list of packages extracted from it. It builds a map
name -> version
that is then passed to the solver. The map is used by the context to promote those version to the top of the preference sorted list of candidates for the package.This result in different versions only getting picked if no solution exist with the version form the previous lock file. New packages are picked as they normally would and package that are not required anymore are also dropped without issues.
In short the preference order allows us to do everything we wanted from that feature making this a very easy to implement yet extremely useful feature!