Skip to content
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

Handle git dependencies with relative pub cache #4494

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/src/source/git.dart
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ class _ValidatedUrl {
}

String _gitDirArg(String path) {
path = p.absolute(path);
final forwardSlashPath =
Platform.isWindows ? path.replaceAll('\\', '/') : path;
return '--git-dir=$forwardSlashPath';
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,4 @@ packages:
source: hosted
version: "2.2.2"
sdks:
dart: ">=3.6.0 <4.0.0"
dart: ">=3.7.0-0 <4.0.0"
32 changes: 32 additions & 0 deletions test/get/git/check_out_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,38 @@ void main() {
expect(packageSpec('foo'), isNotNull);
});

test('checks out a package from Git with relative pub cache', () async {
ensureGit();

await d.git(
'foo.git',
[d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
).create();

await d.appDir(
dependencies: {
'foo': {'git': '../foo.git'},
},
).create();

await pubGet(
environment: {
'PUB_CACHE': './pub_cache/',
},
);

await d.dir(appPath, [
d.dir('pub_cache', [
d.dir('git', [
d.dir('cache', [d.gitPackageRepoCacheDir('foo')]),
d.gitPackageRevisionCacheDir('foo'),
]),
]),
]).validate();

expect(packageSpec('foo')['rootUri'], startsWith('../pub_cache/git/foo-'));
});

test('checks out a package from Git using non-json YAML', () async {
ensureGit();

Expand Down
Loading