diff --git a/lib/src/source/git.dart b/lib/src/source/git.dart index 2c753c653..b0fda4b16 100644 --- a/lib/src/source/git.dart +++ b/lib/src/source/git.dart @@ -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'; diff --git a/pubspec.lock b/pubspec.lock index da40feb75..cc88a70e7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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" diff --git a/test/get/git/check_out_test.dart b/test/get/git/check_out_test.dart index d3a2020de..0a79b4dc3 100644 --- a/test/get/git/check_out_test.dart +++ b/test/get/git/check_out_test.dart @@ -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();