tarides / opam-monorepo

Assemble dune workspaces to build your project and its dependencies as a whole
ISC License
132 stars 27 forks source link

Normalize Github URLs before comparing #365

Closed Leonidas-from-XIV closed 1 year ago

Leonidas-from-XIV commented 1 year ago

This PR tries to normalize the dev-repo URLs somewhat. @TheLortex reported in #118 that the .git is differing between the repos so this PR tries to normalize the URLs:

  1. Always have .git in the repo path
  2. Always use git+https as scheme
  3. Always strip fragments (No more #main)

This is just a workaround since there is no way to make sure the URLs are equivalent without visiting them (especially the .git addition is a bit dodgy), but it should at least cover some common cases and in the worst case the canonicalization gives up and returns the input, thus equivalent to what was there before.

Also turns out there was a Uri_utils.has_git_extension which I assume is somewhat related to the issue at hand, but it was unused so I removed it.

Closes #118

Leonidas-from-XIV commented 1 year ago

I've decided to wrap the normalization in an abstract type to which the conversion only goes one way, to make sure the canonical URLs (whatever they might be) aren't used for other purposes.

Leonidas-from-XIV commented 1 year ago

@emillon You're right, that's a good point. I've simplified the whole thing to just parse user/repo out of github.com URLs and keep the rest the same.

It might make sense to remove the hash/branch, but in practice I doubt someone would specify a git repo with a hash as dev-repo.