Skip to content

Add dependency root support#215

Draft
rtimush wants to merge 1 commit into
masterfrom
repository-root
Draft

Add dependency root support#215
rtimush wants to merge 1 commit into
masterfrom
repository-root

Conversation

@rtimush

@rtimush rtimush commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Currently, protofetch required protofetch.toml to 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 root field 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 root looks similar to content_roots, I don't think we could get away with something like just loading additional descriptors from all specified content_roots. Unlike the new setting, content_roots does 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 root a part of the URL, but there is no common way to do so. The most natural approach would probably be github.com/org/repo/path but 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 root field, 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 that protofetch fetch --locked always produces the same results.

@rtimush rtimush force-pushed the repository-root branch from f224e9d to d20b4f2 Compare June 8, 2026 16:00
@smosca-coralogix

smosca-coralogix commented Jun 9, 2026

Copy link
Copy Markdown

I also considered making root a part of the URL, but there is no common way to do so. The most natural approach would probably be github.com/org/repo/path but this makes URL invalid when open in a browser

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants