Skip to content
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

URLs should allow picking a branch or tag explicitely #11140

Open
Leonidas-from-XIV opened this issue Nov 21, 2024 · 4 comments · May be fixed by #11147
Open

URLs should allow picking a branch or tag explicitely #11140

Leonidas-from-XIV opened this issue Nov 21, 2024 · 4 comments · May be fixed by #11147

Comments

@Leonidas-from-XIV
Copy link
Collaborator

Desired Behavior

When I pin a repo, I want to be able to tell Dune explicitely whether the fragment in the URL is a tag or a branch.

Example

(pin
 (url "git+https://github.com/FStarLang/FStar.git#v0.9.5.0")
 (package
  (name fstar)))

(package (name repro) (depends fstar))

This is currently impossible because v0.9.5.0 is both a branch and a tag in the repo and as a user I have no option to tell Dune which one it is. A possible workaround is to replace the tag with the commit hash, which is mostly workable, but with branches the commit the branch head points to is expected to change so it would require updating the pin all the time.

This ticket is inspired by #11113, which shows that repositories like this exist in the wild and are not just theoretical cases.

@rgrinberg
Copy link
Member

This situation is probably more common than we might think. I believe it arises from the pattern of making a maintenance branch for released versions.

@Leonidas-from-XIV
Copy link
Collaborator Author

Yes, it's also a bit annoying if it used to work (because the tag was created) but stopped (because a branch was created afterwards). The OPAM manual on URLs is surprisingly vague on this. I'll continue to investigate if they have a solution.

Otherwise, the options I see:

  1. Parse the fragment and if it is branch-FOO or tag-FOO (or similar) then assume FOO is a branch or tag respectively.
  2. Allow something like (branch FOO) or (tag FOO) in the definition (and I guess ignore the fragment in the URL? Or keep it in the URL but don't interpret it as reference?)

@rgrinberg
Copy link
Member

I'd like a solution that ideally opam could adopt as well. So I'm not keen on 2.

Leonidas-from-XIV added a commit to Leonidas-from-XIV/dune that referenced this issue Nov 21, 2024
Leonidas-from-XIV added a commit to Leonidas-from-XIV/dune that referenced this issue Nov 21, 2024
@Leonidas-from-XIV
Copy link
Collaborator Author

@kit-ty-kate pointed out that in OPAM the whole path to the reference can be used, so

  1. opam pin add fstar [email protected]:FStarLang/FStar.git#refs/tags/v0.9.5.0
  2. opam pin add fstar [email protected]:FStarLang/FStar.git#refs/heads/v0.9.5.0

This seems fairly sensible as it does not introduce any magic syntax and in my testing it worked just fine, so I've created #11142 as a repro case to implement something similar on the Dune side.

Leonidas-from-XIV added a commit to Leonidas-from-XIV/dune that referenced this issue Nov 21, 2024
Leonidas-from-XIV added a commit that referenced this issue Nov 22, 2024
* test: Add reproduction case for #11140

Signed-off-by: Marek Kubica <[email protected]>

* Fix for non-GNU sed

Signed-off-by: Marek Kubica <[email protected]>

---------

Signed-off-by: Marek Kubica <[email protected]>
Leonidas-from-XIV added a commit to Leonidas-from-XIV/dune that referenced this issue Nov 22, 2024
This reverses the split of branches and tags from ocaml#11127, instead
putting all possible references (e.g. also pull requests) in the same
map and implements short-hands for looking up unqualified refs.

Fixes ocaml#11140

Signed-off-by: Marek Kubica <[email protected]>
Leonidas-from-XIV added a commit to Leonidas-from-XIV/dune that referenced this issue Nov 28, 2024
This reverses the split of branches and tags from ocaml#11127, instead
putting all possible references (e.g. also pull requests) in the same
map and implements short-hands for looking up unqualified refs.

Fixes ocaml#11140

Signed-off-by: Marek Kubica <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants