Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/mod/modresolve: fix stripPrefix for exact match
When a module path exactly matches the prefix that's specified for it, the logic was not stripping the prefix as it should, resulting in unexpected access to the wrong repository. This CL fixes that, and also causes the config file parsing to fail when `stripPrefix` is set and there's no repository specified in the registry, because that would cause an exact match to use the empty repository, which isn't allowed in the OCI spec. Technically it would be possible to allow all modules that have the prefix but don't _exactly_ match the prefix, but that use case seems relatively limited (in practice almost everyone seems to use a repository), and we could always relax that restriction later if we choose. I thought about adding a more end-to-end test in `cmd/cue` but that turns out quite hard to do without duplicating a lot of logic which is unit tested. Instead I manually verified that this scenario does indeed work correctly. Thanks to Erik Mogensen for bringing this issue to attention. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I9e2aeae599cca0b4a161b40c763262338e7007f4 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1178365 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
- Loading branch information