From f114bb2f3d9cc7ca86e76b829c8391a890e12cac Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Thu, 13 Nov 2025 13:10:47 +0000 Subject: [PATCH 1/2] Tag pattern: use hash of referenced commit not of tag itself --- lib/src/source/git.dart | 5 +-- test/get/git/tag_pattern_test.dart | 58 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) 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..45c952ef9d 100644 --- a/test/get/git/tag_pattern_test.dart +++ b/test/get/git/tag_pattern_test.dart @@ -379,4 +379,62 @@ 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(); + await d.git('foo.git', []).tag('1.0.0'); + + 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'}, + ); + }, + ); } From 627428b99658e42e346b7381dd4ecbd52c6b4c0b Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Fri, 14 Nov 2025 08:56:22 +0000 Subject: [PATCH 2/2] Test for actual resolved ref in test --- test/get/git/tag_pattern_test.dart | 50 ++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/test/get/git/tag_pattern_test.dart b/test/get/git/tag_pattern_test.dart index 45c952ef9d..6f6ef0c8d4 100644 --- a/test/get/git/tag_pattern_test.dart +++ b/test/get/git/tag_pattern_test.dart @@ -381,7 +381,7 @@ void main() { ); test( - 'Multiple path dependencies to same package work (regression https://github.com/dart-lang/pub/issues/4706)', + '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', [ @@ -407,7 +407,9 @@ void main() { ]), d.dir('three', [d.libPubspec('three', '1.0.0', sdk: '^3.9.0')]), ]).create(); - await d.git('foo.git', []).tag('1.0.0'); + final g = d.git('foo.git', []); + await g.tag('1.0.0'); + final ref = await g.revParse('HEAD'); await d .appDir( @@ -435,6 +437,50 @@ void main() { ), 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', + }); }, ); }