Skip to content

Conversation

@Leonidas-from-XIV
Copy link
Collaborator

This PR applies #13176 and adds the remaining code to implement the behavior discussed in #13110. The tests change accordingly with the changed semantics of git URLs.

Closes #13110

@Leonidas-from-XIV Leonidas-from-XIV force-pushed the lock-git-revision-take-2 branch 2 times, most recently from d669f81 to 64a79d3 Compare January 12, 2026 22:01
(match url.backend with
| `git ->
(match Resolved_package.at_rev resolved_pkg with
| None -> url
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case happens when it is a dune pin or it is a files directory opam pin. Is that what we want here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't work out how this can be None, if it is really impossible we should Code_error instead of falling back.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a Code_error.raise but the tests in opam-source-conversion.t are failing. Need to investigate this, because they might be resolving the packages incorrectly as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so this branch triggers when this is happening in opam-source-conversion.t:

  $ mkpkg testpkg <<EOF
  > url {
  >   src: "git+http://github.com/foo"
  >   checksum: "md5=069aa55d40e548280f92af693f6c625a"
  > }
  > EOF

This is because the URL is a Git URL, but the resolved package testpkg actually comes from the file system (the mock repo), thus it is loaded via Resolved_package.local_fs which does not load an At_rev.t (and should not need to).

It seems like relying on the Resolved_package to read the revision from is wrong in the general case, as the Resolved_package only matches the source when pinning or vendoring but does not when the package is loaded from an OPAM repo (at which point the Resolved_package is in the OPAM repo and completely disconnected from the actual source).

Copy link
Collaborator

@Alizter Alizter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add test cases for branches and tags?

@Leonidas-from-XIV Leonidas-from-XIV marked this pull request as draft January 14, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pinning a git repo should record the hash of the repository in the lock

2 participants