Skip to content

Commit 469eb61

Browse files
authored
Fix tag_pattern lockfile deserialization (#4646)
1 parent befc0a1 commit 469eb61

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

lib/src/source/git.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class GitSource extends CachedSource {
171171
);
172172
}
173173

174-
final tagPattern = description['tag_pattern'];
174+
final tagPattern = description['tag-pattern'];
175175
if (tagPattern is! String?) {
176176
throw const FormatException(
177177
"The 'tag_pattern' field of the description "

test/get/git/tag_pattern_test.dart

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,70 @@ void main() {
313313
),
314314
);
315315
});
316+
317+
// Regression test for https://github.com/dart-lang/pub/issues/4644.
318+
test(
319+
'Lockfile persists tag-pattern when `pub get`ing already locked file',
320+
() async {
321+
ensureGit();
322+
await d.git('foo.git', [
323+
d.libPubspec('foo', '1.0.0', sdk: '^3.9.0'),
324+
]).create();
325+
await d.git('foo.git', []).tag('1.0.0');
326+
327+
await d
328+
.appDir(
329+
dependencies: {
330+
'foo': {
331+
'git': {
332+
'url': p.join(d.sandbox, 'foo.git'),
333+
'tag_pattern': '{{version}}',
334+
},
335+
},
336+
},
337+
pubspec: {
338+
'environment': {'sdk': '^3.9.0'},
339+
},
340+
)
341+
.create();
342+
343+
await pubGet(
344+
output: allOf(contains('+ foo 1.0.0')),
345+
environment: {'_PUB_TEST_SDK_VERSION': '3.9.0'},
346+
);
347+
final lockfile = loadYaml(
348+
File(p.join(d.sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
349+
);
350+
final s = Platform.pathSeparator;
351+
final foo = ((lockfile as Map)['packages'] as Map)['foo'];
352+
expect(foo, {
353+
'dependency': 'direct main',
354+
'description': {
355+
'path': '.',
356+
'resolved-ref': isA<String>(),
357+
'tag-pattern': '{{version}}',
358+
'url': '${d.sandbox}${s}foo.git',
359+
},
360+
'source': 'git',
361+
'version': '1.0.0',
362+
});
363+
await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.9.0'});
364+
final lockfile2 = loadYaml(
365+
File(p.join(d.sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
366+
);
367+
final foo2 = ((lockfile2 as Map)['packages'] as Map)['foo'];
368+
369+
expect(foo2, {
370+
'dependency': 'direct main',
371+
'description': {
372+
'path': '.',
373+
'resolved-ref': isA<String>(),
374+
'tag-pattern': '{{version}}',
375+
'url': '${d.sandbox}${s}foo.git',
376+
},
377+
'source': 'git',
378+
'version': '1.0.0',
379+
});
380+
},
381+
);
316382
}

0 commit comments

Comments
 (0)