-
Notifications
You must be signed in to change notification settings - Fork 233
Allow relative path-dependencies from git dependencies #4060
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
Conversation
| sources, | ||
| expectedName: name, | ||
| allowOverridesFile: withPubspecOverrides, | ||
| containingDescription: RootDescription(dir), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if this is right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this to take an explicit description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks sound, but I'm not 100% sure.
Could we try to split it into smaller PRs. Some of the refactoring, renaming, etc, could be done in separate PRs.
Even the changes in behavior that we're doing to RootSource could be done in a separate PR.
We could possibly even introduce containingDescription in a PR without modifying PathSource to return GitDescription objects just yet.
I see how it makes sense to get everything working. But it would be a LOT faster to review one aspect of the changes at the time.
And we'd be more confident we're not missing something.
- I'm a little confused about the root/entrypoint names.
- The
PackageGraphstuff looks like a possible footgun in the future (though it might already be one). - The changes in
RootSourceI don't know about (maybe it's a minor concern). - All the places we put in the wrong
containingDescriptionbecause we don't care, scares me a bit... Should we make anUnknownDescriptionwe can put in? Just an idea 🤣 - Should we have a test cases where we have a diamond dependency. Ie. two git-dependencies from the same repo that both have a the same path-dependency.
lib/src/source.dart
Outdated
| String name, | ||
| Object? description, { | ||
| String? containingDir, | ||
| Description? containingDescription, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update documentation and explain in excruciating details what this is :D
Also I'm a bit curious, why is it not the referencing pubspec?
Is the the snippet of the pubspec that references this dependency?
Description is very overloaded and hard to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - maybe we need to think a bit more here.
A "description" is the abstract form of what you find in a pubspec on the right-hand side of a dependency-colon.
dependencies:
retry: # here comes the description
The containingDescription is the description of the pubspec that referenced the one you are parsing now.
Eg. if your root pubspec, it is described by a RootDescription, because it is not a reference from another pubspec, has:
dependencies:
retry:
git: https://github.com/abc/retry
Then you would parse the retry pubspec.yaml with a RootDescription as the containingDescription.
I'll try to make a better documentation...
lib/src/package.dart
Outdated
| /// Loads the package whose root directory is [packageDir] as a root package. | ||
| factory Package.entrypoint( | ||
| String dir, | ||
| SourceRegistry sources, | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In workspaces should we call the workspaces packages for entrypoints and then have isEntrypoint instead of isRoot all over the solver?
Other places I see PackageRef.root(..., so should this be Package.root instead?
lib/src/source/hosted.dart
Outdated
| packages.add(Package.load(null, entry, cache.sources)); | ||
| // We are loading as an entrypoint because we don't look at the | ||
| // dependencies, so they do not have to be interpreted relative to | ||
| // anything. | ||
| packages.add(Package.entrypoint(entry, cache.sources)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The move away from Package.load(null, ... ) is orthogonal and could have been done in a separate PR is that correct?
lib/src/command/add.dart
Outdated
| cache.sources, | ||
| // Resolve relative paths relative to current, not where the pubspec.yaml is. | ||
| location: p.toUri(p.join(p.current, 'descriptor')), | ||
| containingDescription: RootDescription('.'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not RootDescription(entrypoint.rootDir), just asking? I'm guessing it doesn't matter at all?
if it doesn't matter then why not null ?
|
|
||
| Package? _root; | ||
|
|
||
| /// The root package this entrypoint is associated with. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should documentation say "entrypoint package"
Do we want to reuse this word, instead of root. If so maybe this should be a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for now "root" is good enough. With workspaces we might really have to change stuff
lib/src/source/root.dart
Outdated
| // final description = id.description.description; | ||
| // if (description is! RootDescription) { | ||
| // throw ArgumentError('Wrong source'); | ||
| // } | ||
| // return description.package.pubspec; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this either an UnsupportedError or an AssertionError?
This should never happen, right? so AssertionError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commented out code was not intentional
lib/src/source/root.dart
Outdated
| throw ArgumentError('Trying to get versions of the root package'); | ||
|
|
||
| // final description = ref.description; | ||
| // if (description is! RootDescription) { | ||
| // throw ArgumentError('Wrong source'); | ||
| // } | ||
| // return [PackageId.root(description.package)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this either an UnsupportedError or an AssertionError?
This should never happen, right? so AssertionError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also ArgumentErrors should never happen... I don't really care. In my small universe AssertionErrors are reserved for assertions (that are disabled when not running with assertions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to UnsupportedError
lib/src/package.dart
Outdated
|
|
||
| RootDescription get description => RootDescription(_dir); | ||
| ResolvedRootDescription get resolvedDescription => | ||
| ResolvedRootDescription(description); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? Documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed nonsense
| if (id.isRoot) { | ||
| pubspec = _rootPubspec!; | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this now?
Is it because we changed what RootSource can do? Is this wise?
Should we consider moving some of these refactorings into separate PRs.
| } | ||
|
|
||
| class GitResolvedDescription extends ResolvedDescription { | ||
| class ResolvedGitDescription extends ResolvedDescription { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rename is completely orthogonal to the rest of the PR, right?
Should we consider doing it in a separate PR upfront, so there is less to review here?
(the rename seems like something that would be easy to review and land)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aye - this is now #4138
1f79a48 to
840510b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should be a lot more manageable now.
PTAL
The paths are interpreted as paths inside the same git repo (at the same ref).
Internally, and in the lock-file they are treated as git-dependencies.
We do this by always interpreting dependencies in the context of the
Descriptionof the pubspec that contains it. This mechanism is now also used for passing the path relative path-dependencies are relative against. Much more streamlined!We have to change how RootDescription is behaving, because the description now has to be created before we parse the pubspec it cannot know the Package object it belongs to, but just the path. (necessitating a bit of caching for everything to line up).
This fixes #449