Skip to content

Commit

Permalink
Handle git dependencies with relative pub cache (#4494)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm authored Jan 16, 2025
1 parent 6a10104 commit eaf03b3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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

0 comments on commit eaf03b3

Please sign in to comment.