-
Notifications
You must be signed in to change notification settings - Fork 462
Use git_repo to pin git packages
#13176
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
Use git_repo to pin git packages
#13176
Conversation
|
Can you add some tests? |
|
The |
|
I guess the description makes it sound like this is a fix, but is it just a refactoring? |
|
This refactoring is needed I guess in order to include the revision of the pinned git repo in the lock. Might be worth opening a PR with that fix so we can see the direction this is going. |
| opam_package | ||
| | Git at_rev -> | ||
| let opam_file_contents = OpamFile.OPAM.write_to_string opam_file in | ||
| (* when pinning there is no files dir nor does it make sense *) |
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.
This comment is incorrect. When pinning a package with a root directory opam/, the files directory is opam/files.
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.
Actually, my comment is also incorrect. Because we're pinning a dune package, there's no files directory. Because at the moment, we don't allow users to define such a directory.
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.
Nope, looks like my original comment was correct. The pin is what is from dune here, not the package type. And dune pins can be used on opam packages which may contain an opam/files directory.
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.
Interesting. I've never encountered such a package (and it seems a bit pointless, because in such cases the files could just be part of the repo/tarball itself).
Where is the opam file in such case? Does it have to be in opam/ or can it be in the root?
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.
Interesting. I've never encountered such a package (and it seems a bit pointless, because in such cases the files could just be part of the repo/tarball itself).
I recall running into this at some point. I agree it's exceedingly rare.
Interesting. I've never encountered such a package (and it seems a bit pointless, because in such cases the files could just be part of the repo/tarball itself).
In such a case, the opam file would be opam/opam.
I think we should add a test for this if we haven't one yet. We don't necessarily need to support this feature, but having a good error message that we don't support pinning such a package would be the least we could do.
src/dune_pkg/pin.ml
Outdated
| opam_file | ||
| opam_package | ||
| | Git at_rev -> | ||
| let opam_file_contents = OpamFile.OPAM.write_to_string opam_file in |
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.
Something is off here. Why are we turning this value into a string just so that we can parse it back later?
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.
To me it seems the issue is that Resolved_package.{local_package,local_fs,git_repo} have a very inconsistent API. local_package takes an OpamFile.OPAM.t whereas git_repo gets a string and a path and constructs an OpamFile.OPAM.t itself.
local_fs does not take an OpamFile.OPAM.t at all, it just takes the path and reads that path from the file system to get an OpamFile.OPAM.t.
In general I think that Resolved_package.{git_repo,local_fs} should take an OpamFile.OPAM.t as argument and how that is constructed (be it through reading from a local path or consulting the rev-store) is up to the caller.
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.
Right, it might suck but let's fix it instead of piling on.
In general I think that Resolved_package.{git_repo,local_fs} should take an OpamFile.OPAM.t as argument and how that is constructed (be it through reading from a local path or consulting the rev-store) is up to the caller.
Yeah, that sounds fine. Make sure to maintain the other functionality that Resolved_package.read_opam_file does though.
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.
Opened #13216 to implement that.
Unfortunately, this isn't correct. From reading the code, the
One can pin a dune package (a package built with dune) via an opam pin, so we cannot make this assumption:
I think the tests are all passing because we simply don't have a test case for this. The reason why we need to know what kind of a package it is is to generate the correct build command for packages that are built with dune. Sorry for the confusing naming, I had to understand everything from scratch myself. |
|
Thanks for the input; this is all very interesting to start to understand how the whole pinning mechanism works!
Yeah honestly I am a bit confused by the entirety of the code. The code in So maybe it fixes something, but as far I see there is nothing broken, just a
Hmm, in that case I can also implement a similar guessing logic as |
abb1c93 to
0c447b9
Compare
I think the challenge with that is that
To re-iterate what i said earlier, although we have a massive amount of tests, they're by no means exhaustive. I think that pinning both dune and opam packages is simply not tested at the moment.
That makes no sense to me either and I don't see how it can work. My understanding is that |
) Pulled out of #13176. --------- Signed-off-by: Marek Kubica <marek@tarides.com>
…13216) As a follow-up to #13176 (comment) this refactors the `Resolved_package` API so the functions that construct a `Resolved_package.t` take somewhat similar arguments, i.e. an `OpamFile.OPAM.t`. This should make it easier to call the right function at the right place. --------- Signed-off-by: Marek Kubica <marek@tarides.com>
Signed-off-by: Marek Kubica <marek@tarides.com>
Signed-off-by: Marek Kubica <marek@tarides.com>
0c447b9 to
21ba4a4
Compare
|
Turns out this wasn't really necessary (nor particularly helpful, as the |
While trying to figure out which revision a package that is pinned via git is, I realized that for some reason packages pinned via Git are pinned as
Resolved_package.local_package. I would have expected it to begit_repowhich also gets anAt_rev.t(thus keeping a reference to it that I can read later), so I updated the code to do so.Tests seem to all work fine after fixing
git_reposo that it can build packages with Dune. Detecting whether a package builds with Dune is a bit fiddly but beforegit_repoalways assumedfalseso I've retained that for the other invocations ofgit_repoand in the pinning case I know that the repo to be pinned uses Dune so I can set it totrue, thus I can avoid guessing.