diff --git a/lib/src/source/git.dart b/lib/src/source/git.dart index 9087944659..fa7e6fbc01 100644 --- a/lib/src/source/git.dart +++ b/lib/src/source/git.dart @@ -772,8 +772,9 @@ class GitSource extends CachedSource { '--list', '--format', // We can use space here, as it is not allowed in a git tag - // https://git-scm.com/docs/git-check-ref-format - '%(refname:lstrip=2) %(objectname)', + // https://git-scm.com/docs/git-check-ref-format The `*` means we list the + // hash of the tagged object, not the tag itself. + '%(refname:lstrip=2) %(*objectname)', ], workingDir: path); final lines = output.trim().split('\n'); final result = []; diff --git a/test/get/git/tag_pattern_test.dart b/test/get/git/tag_pattern_test.dart index 732ca40839..6f6ef0c8d4 100644 --- a/test/get/git/tag_pattern_test.dart +++ b/test/get/git/tag_pattern_test.dart @@ -379,4 +379,108 @@ void main() { }); }, ); + + test( + 'multiple path dependencies to same package work (regression https://github.com/dart-lang/pub/issues/4706)', + () async { + await d.git('foo.git', [ + d.dir('one', [ + d.libPubspec( + 'one', + '1.0.0', + sdk: '^3.9.0', + deps: { + 'two': {'path': '../two'}, + 'three': {'path': '../three'}, + }, + ), + ]), + d.dir('two', [ + d.libPubspec( + 'two', + '1.0.0', + sdk: '^3.9.0', + deps: { + 'three': {'path': '../three'}, + }, + ), + ]), + d.dir('three', [d.libPubspec('three', '1.0.0', sdk: '^3.9.0')]), + ]).create(); + final g = d.git('foo.git', []); + await g.tag('1.0.0'); + final ref = await g.revParse('HEAD'); + + await d + .appDir( + dependencies: { + 'one': { + 'git': { + 'url': '../foo.git', + 'path': 'one', + 'tag_pattern': '{{version}}', + }, + 'version': '^1.0.0', + }, + }, + pubspec: { + 'environment': {'sdk': '^3.9.0'}, + }, + ) + .create(); + + await pubGet( + output: allOf( + contains('+ one 1.0.0'), + contains('+ two 1.0.0'), + contains('+ three 1.0.0'), + ), + environment: {'_PUB_TEST_SDK_VERSION': '3.9.0'}, + ); + final lockfile = + loadYaml( + File( + p.join(d.sandbox, appPath, 'pubspec.lock'), + ).readAsStringSync(), + ) + as Map; + final packages = lockfile['packages'] as Map; + final one = packages['one']; + expect(one, { + 'dependency': 'direct main', + 'description': { + 'path': 'one', + 'resolved-ref': ref, + 'tag-pattern': '{{version}}', + 'url': '../foo.git', + }, + 'source': 'git', + 'version': '1.0.0', + }); + final two = packages['two']; + expect(two, { + 'dependency': 'transitive', + 'description': { + 'path': 'two', + 'resolved-ref': ref, + 'tag-pattern': '{{version}}', + 'url': '../foo.git', + }, + 'source': 'git', + 'version': '1.0.0', + }); + final three = packages['three']; + expect(three, { + 'dependency': 'transitive', + 'description': { + 'path': 'three', + 'resolved-ref': ref, + 'tag-pattern': '{{version}}', + 'url': '../foo.git', + }, + 'source': 'git', + 'version': '1.0.0', + }); + }, + ); }