Skip to content

Fix opam file lookup when a pin is done with a local directory and a branch is specified #6409

Draft
rjbou wants to merge 2 commits intoocaml:masterfrom
rjbou:pin-magic-local-opam-branch-fix
Draft

Fix opam file lookup when a pin is done with a local directory and a branch is specified #6409
rjbou wants to merge 2 commits intoocaml:masterfrom
rjbou:pin-magic-local-opam-branch-fix

Conversation

@rjbou
Copy link
Copy Markdown
Collaborator

@rjbou rjbou commented Mar 5, 2025

fix #6408
I'm not fully satisfied with that solution... But it may not be kept, superseded by #6419.

This PR changes the behaviour of opam pin add ./local-vcs which would take the opam files from the VCS repository even if they had untracked changes. This behaviour exists since opam 2.1 (see #4300) but opam 2.0 didn't have the same behaviour.
The addition of a note about untracked changes can be added separately and is tracked by #6414

@rjbou rjbou added KIND: BUG PR: WIP Not for merge at this stage labels Mar 5, 2025
@kit-ty-kate
Copy link
Copy Markdown
Member

kit-ty-kate commented Mar 8, 2025

After lengthy reviewing and tinkering i wasn't satisfied with the solution either so i came up with a different proposal, which while a bit radical i strongly believe to be a positive change for users:

Currently pinning a local vcs directory will override the opam files with whatever the version in the working directory is, regardless of whether or not --working-dir is given. I think this behaviour is too surprising to users. If they wish to use the working directory version then they can pass --working-dir explicitly. This also has the side-effect to simplify our code quite a lot which is always nice.

I've pushed the proposal as the fixup proposal commit above. The parent fixup commit implements a couple of cleanups (probably mostly redundant if the proposal is to be accepted), and i've also added a commit at the top to change the return type of OpamRepository.revision which shouldn't have had the version type.

What do you think?

@kit-ty-kate kit-ty-kate force-pushed the pin-magic-local-opam-branch-fix branch from 413eee3 to ec45d71 Compare March 10, 2025 18:16
@kit-ty-kate kit-ty-kate changed the title Fix opam file lookup when a pin is done with a local directory and a branch is specified Stop using the untracked local opam file on opam pin ./local-vcs Mar 10, 2025
@kit-ty-kate kit-ty-kate removed the PR: WIP Not for merge at this stage label Mar 10, 2025
@rjbou rjbou force-pushed the pin-magic-local-opam-branch-fix branch from ec45d71 to ff6dae3 Compare March 13, 2025 16:25
@rjbou rjbou changed the title Stop using the untracked local opam file on opam pin ./local-vcs Fix opam file lookup when a pin is done with a local directory and a branch is specified Mar 13, 2025
@rjbou
Copy link
Copy Markdown
Collaborator Author

rjbou commented Mar 13, 2025

Putting back the PR to its original state as the fix of #6408. I've opened #6418 to discuss default behaviour change and #6419 the part of the PR that contains the wip.

Copy link
Copy Markdown
Member

@kit-ty-kate kit-ty-kate left a comment

Choose a reason for hiding this comment

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

I strongly believe the magic should be removed all together instead as mentioned above

@kit-ty-kate kit-ty-kate marked this pull request as draft March 13, 2025 16:33
@rjbou rjbou added the PR: WIP Not for merge at this stage label Mar 27, 2025
@rjbou rjbou modified the milestones: 2.4.0~alpha1, 2.5.0~alpha1 Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

KIND: BUG PR: WIP Not for merge at this stage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opam pin ./local#mybranch does not take mybranch opam file

2 participants