Add dependency root support#215
Draft
rtimush wants to merge 1 commit into
Draft
Conversation
They are a nuisance to open, but these kinds of URLs are already very common in Go. I must say that I would like this solution a bit more because of this precedent, but definitely not enough to say it is always better |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, protofetch required
protofetch.tomlto be in the root of the repository.This is not particularly friendly to the cases when proto files are only a part of what's in the repository, and does not work at all if we want to have more than one protofetch module in one repository.
This PR adds a new optional
rootfield to the dependency definition in the module descriptor. When set, it is treated as if it was the root of the repository — the descriptor is loaded from this path, content roots and policy settings apply relatively to the root.While
rootlooks similar tocontent_roots, I don't think we could get away with something like just loading additional descriptors from all specifiedcontent_roots. Unlike the new setting,content_rootsdoes not apply any filter to the files, it only makes protofetch remove the prefix from matching files, but proto files outside of the content roots are still included.I also considered making
roota part of the URL, but there is no common way to do so. The most natural approach would probably begithub.com/org/repo/pathbut this makes URL invalid when open in a browser, which could be confusing.The change is not forward compatible: old protofetch versions will ignore the
rootfield, fetching wrong protos (or most likely rather not fetching the right ones). I'm not sure if we have a good way to deal with such incompatibilities though. Maybe we can bump a version in the lockfile — it won't fix all issues, but at least we will make sure thatprotofetch fetch --lockedalways produces the same results.