Skip to content

Commit f114bb2

Browse files
committed
Tag pattern: use hash of referenced commit not of tag itself
1 parent 28791d3 commit f114bb2

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

lib/src/source/git.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,9 @@ class GitSource extends CachedSource {
772772
'--list',
773773
'--format',
774774
// We can use space here, as it is not allowed in a git tag
775-
// https://git-scm.com/docs/git-check-ref-format
776-
'%(refname:lstrip=2) %(objectname)',
775+
// https://git-scm.com/docs/git-check-ref-format The `*` means we list the
776+
// hash of the tagged object, not the tag itself.
777+
'%(refname:lstrip=2) %(*objectname)',
777778
], workingDir: path);
778779
final lines = output.trim().split('\n');
779780
final result = <TaggedVersion>[];

test/get/git/tag_pattern_test.dart

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,62 @@ void main() {
379379
});
380380
},
381381
);
382+
383+
test(
384+
'Multiple path dependencies to same package work (regression https://github.com/dart-lang/pub/issues/4706)',
385+
() async {
386+
await d.git('foo.git', [
387+
d.dir('one', [
388+
d.libPubspec(
389+
'one',
390+
'1.0.0',
391+
sdk: '^3.9.0',
392+
deps: {
393+
'two': {'path': '../two'},
394+
'three': {'path': '../three'},
395+
},
396+
),
397+
]),
398+
d.dir('two', [
399+
d.libPubspec(
400+
'two',
401+
'1.0.0',
402+
sdk: '^3.9.0',
403+
deps: {
404+
'three': {'path': '../three'},
405+
},
406+
),
407+
]),
408+
d.dir('three', [d.libPubspec('three', '1.0.0', sdk: '^3.9.0')]),
409+
]).create();
410+
await d.git('foo.git', []).tag('1.0.0');
411+
412+
await d
413+
.appDir(
414+
dependencies: {
415+
'one': {
416+
'git': {
417+
'url': '../foo.git',
418+
'path': 'one',
419+
'tag_pattern': '{{version}}',
420+
},
421+
'version': '^1.0.0',
422+
},
423+
},
424+
pubspec: {
425+
'environment': {'sdk': '^3.9.0'},
426+
},
427+
)
428+
.create();
429+
430+
await pubGet(
431+
output: allOf(
432+
contains('+ one 1.0.0'),
433+
contains('+ two 1.0.0'),
434+
contains('+ three 1.0.0'),
435+
),
436+
environment: {'_PUB_TEST_SDK_VERSION': '3.9.0'},
437+
);
438+
},
439+
);
382440
}

0 commit comments

Comments
 (0)