-
Notifications
You must be signed in to change notification settings - Fork 211
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
fix: fix git dependencies comparison on bootstrap #659
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,126 @@ Generating IntelliJ IDE files... | |
); | ||
}); | ||
|
||
test('properly compares the path changes on git references', () async { | ||
final temporaryGitRepository = createTestTempDir(); | ||
|
||
await io.Process.run( | ||
'git', | ||
['init'], | ||
workingDirectory: temporaryGitRepository.absolute.path, | ||
); | ||
|
||
await createProject( | ||
io.Directory('${temporaryGitRepository.absolute.path}/dependency1'), | ||
const PubSpec(name: 'dependency'), | ||
); | ||
|
||
await createProject( | ||
io.Directory('${temporaryGitRepository.absolute.path}/dependency2'), | ||
const PubSpec(name: 'dependency'), | ||
); | ||
|
||
await io.Process.run( | ||
'git', | ||
['add', '-A'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty directories won't be added to git, maybe create an empty file in both of the directories first? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The directory, supposedly, is not empty, as we created two projects within it with If this was not the case, the test would not pass in my local machine either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, I read There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am going to try to reproduce the problem by using a container locally and running the same images. Maybe I can debug this way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, I re-ran the failing test with GitHub debug printing, but it didn't give anything There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mateusfccp did you manage to find anything causing it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello, @spydon. Sorry for the delay. I actually didn't get to reproduce the environment on my local machine. I tried to do it with |
||
workingDirectory: temporaryGitRepository.absolute.path, | ||
); | ||
|
||
await io.Process.run( | ||
'git', | ||
['commit', '--message="Initial commit"'], | ||
workingDirectory: temporaryGitRepository.absolute.path, | ||
); | ||
|
||
final workspaceDirectory = await createTemporaryWorkspace(); | ||
|
||
final initialReference = { | ||
'git': { | ||
'url': 'file://${temporaryGitRepository.absolute.path}', | ||
'path': 'dependency1/packages/dependency', | ||
}, | ||
}; | ||
|
||
final package = await createProject( | ||
workspaceDirectory, | ||
PubSpec( | ||
name: 'git_references', | ||
dependencies: { | ||
'dependency': GitReference.fromJson(initialReference), | ||
}, | ||
), | ||
); | ||
|
||
final logger = TestLogger(); | ||
final initialConfig = MelosWorkspaceConfig.fromYaml( | ||
{ | ||
'name': 'test', | ||
'packages': const ['packages/**'], | ||
'command': { | ||
'bootstrap': { | ||
'dependencies': { | ||
'dependency': initialReference, | ||
}, | ||
}, | ||
}, | ||
}, | ||
path: workspaceDirectory.path, | ||
); | ||
|
||
final melosBeforeChangingPath = Melos( | ||
logger: logger, | ||
config: initialConfig, | ||
); | ||
|
||
await runMelosBootstrap(melosBeforeChangingPath, logger); | ||
|
||
final packageConfig = packageConfigForPackageAt(package); | ||
final dependencyPackage = packageConfig.packages.singleWhere( | ||
(package) => package.name == 'dependency', | ||
); | ||
|
||
expect( | ||
dependencyPackage.rootUri, | ||
contains('dependency1/packages/dependency'), | ||
); | ||
|
||
final configWithChangedPath = MelosWorkspaceConfig.fromYaml( | ||
{ | ||
'name': 'test', | ||
'packages': const ['packages/**'], | ||
'command': { | ||
'bootstrap': { | ||
'dependencies': { | ||
'dependency': { | ||
'git': { | ||
'url': 'file://${temporaryGitRepository.absolute.path}', | ||
'path': 'dependency2/packages/dependency', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
path: workspaceDirectory.path, | ||
); | ||
|
||
final melosAfterChangingPath = Melos( | ||
logger: logger, | ||
config: configWithChangedPath, | ||
); | ||
|
||
await runMelosBootstrap(melosAfterChangingPath, logger); | ||
|
||
final alteredPackageConfig = packageConfigForPackageAt(package); | ||
final alteredDependencyPackage = alteredPackageConfig.packages | ||
.singleWhere((package) => package.name == 'dependency'); | ||
|
||
expect( | ||
alteredDependencyPackage.rootUri, | ||
contains('dependency2/packages/dependency'), | ||
); | ||
}); | ||
|
||
test( | ||
'resolves workspace packages with path dependency', | ||
() async { | ||
|
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.
It is replaced with pubspec_parse now
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.
Is this PR obsolete or does the bug still exist? I am updating it, but I realized that the package has changed and I am not sure if it solves the problem by itself.
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'm not sure. Can you try running
main
?