Skip to content

Commit eaf03b3

Browse files
authored
Handle git dependencies with relative pub cache (#4494)
1 parent 6a10104 commit eaf03b3

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

lib/src/source/git.dart

+1
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ class _ValidatedUrl {
916916
}
917917

918918
String _gitDirArg(String path) {
919+
path = p.absolute(path);
919920
final forwardSlashPath =
920921
Platform.isWindows ? path.replaceAll('\\', '/') : path;
921922
return '--git-dir=$forwardSlashPath';

pubspec.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,4 @@ packages:
479479
source: hosted
480480
version: "2.2.2"
481481
sdks:
482-
dart: ">=3.6.0 <4.0.0"
482+
dart: ">=3.7.0-0 <4.0.0"

test/get/git/check_out_test.dart

+32
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,38 @@ void main() {
5151
expect(packageSpec('foo'), isNotNull);
5252
});
5353

54+
test('checks out a package from Git with relative pub cache', () async {
55+
ensureGit();
56+
57+
await d.git(
58+
'foo.git',
59+
[d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
60+
).create();
61+
62+
await d.appDir(
63+
dependencies: {
64+
'foo': {'git': '../foo.git'},
65+
},
66+
).create();
67+
68+
await pubGet(
69+
environment: {
70+
'PUB_CACHE': './pub_cache/',
71+
},
72+
);
73+
74+
await d.dir(appPath, [
75+
d.dir('pub_cache', [
76+
d.dir('git', [
77+
d.dir('cache', [d.gitPackageRepoCacheDir('foo')]),
78+
d.gitPackageRevisionCacheDir('foo'),
79+
]),
80+
]),
81+
]).validate();
82+
83+
expect(packageSpec('foo')['rootUri'], startsWith('../pub_cache/git/foo-'));
84+
});
85+
5486
test('checks out a package from Git using non-json YAML', () async {
5587
ensureGit();
5688

0 commit comments

Comments
 (0)