Skip to content

Commit 98b36da

Browse files
committed
update
1 parent f48f440 commit 98b36da

File tree

3 files changed

+47
-25
lines changed

3 files changed

+47
-25
lines changed

script/tool/lib/src/version_check_command.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,16 @@ class VersionCheckCommand extends PackageLoopingCommand {
232232

233233
// The changelog.md and pubspec.yaml's version should not be updated directly.
234234
if (changedFiles.contains(package.changelogFile.path)) {
235+
printError(
236+
'This package uses batch release, so CHANGELOG.md should not be changed directly.\n'
237+
'Instead, create a pending changelog file in pending_changelogs folder.');
235238
errors.add('CHANGELOG.md changed');
236239
}
237240
if (changedFiles.contains(package.pubspecFile.path)) {
238241
if (versionState != _CurrentVersionState.unchanged) {
242+
printError(
243+
'This package uses batch release, so the version in pubspec.yaml should not be changed directly.\n'
244+
'Instead, create a pending changelog file in pending_changelogs folder.');
239245
errors.add('pubspec.yaml version changed');
240246
}
241247
}

script/tool/test/common/repository_package_test.dart

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,12 @@ release:
277277
createFakePlugin('a_plugin', packagesDir);
278278
plugin.ciConfigFile.writeAsStringSync('not a map');
279279

280-
expect(() => plugin.parseCiConfig(), throwsFormatException);
280+
expect(
281+
() => plugin.parseCiConfig(),
282+
throwsA(isA<FormatException>().having(
283+
(FormatException e) => e.message,
284+
'message',
285+
contains('Root of ci_config.yaml must be a map'))));
281286
});
282287

283288
test('reports unknown keys', () {
@@ -287,7 +292,12 @@ release:
287292
foo: bar
288293
''');
289294

290-
expect(() => plugin.parseCiConfig(), throwsFormatException);
295+
expect(
296+
() => plugin.parseCiConfig(),
297+
throwsA(isA<FormatException>().having(
298+
(FormatException e) => e.message,
299+
'message',
300+
contains('Unknown key `foo` in config'))));
291301
});
292302

293303
test('reports invalid values', () {
@@ -298,7 +308,12 @@ release:
298308
batch: not-a-bool
299309
''');
300310

301-
expect(() => plugin.parseCiConfig(), throwsFormatException);
311+
expect(
312+
() => plugin.parseCiConfig(),
313+
throwsA(isA<FormatException>().having(
314+
(FormatException e) => e.message,
315+
'message',
316+
contains('Invalid value `not-a-bool` for key `release.batch`'))));
302317
});
303318
});
304319

@@ -356,7 +371,12 @@ version: minor
356371
package.pendingChangelogsDirectory.childFile('a.yaml');
357372
changelogFile.writeAsStringSync('not yaml');
358373

359-
expect(() => package.getPendingChangelogs(), throwsFormatException);
374+
expect(
375+
() => package.getPendingChangelogs(),
376+
throwsA(isA<FormatException>().having(
377+
(FormatException e) => e.message,
378+
'message',
379+
contains('Expected a YAML map, but found String'))));
360380
});
361381

362382
test('ignores template.yaml', () {
@@ -382,22 +402,5 @@ version: skip
382402
expect(changelogs, hasLength(1));
383403
expect(changelogs[0].changelog, 'A');
384404
});
385-
386-
test('returns an error for a non-yaml file', () {
387-
final RepositoryPackage package =
388-
createFakePackage('a_package', packagesDir);
389-
package.pendingChangelogsDirectory.createSync();
390-
package.pendingChangelogsDirectory
391-
.childFile('a.yaml')
392-
.writeAsStringSync('''
393-
changelog: A
394-
version: patch
395-
''');
396-
package.pendingChangelogsDirectory
397-
.childFile('a.txt')
398-
.writeAsStringSync('text');
399-
400-
expect(() => package.getPendingChangelogs(), throwsFormatException);
401-
});
402405
});
403406
}

script/tool/test/version_check_command_test.dart

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,28 @@ void main() {
322322
]));
323323
});
324324

325-
test('skips version check with post-release label', () async {
325+
test(
326+
'ignore changelog and pubspec yaml version modifications check with post-release label',
327+
() async {
326328
final RepositoryPackage package =
327329
createFakePackage('package', packagesDir, version: '1.0.0');
328330
package.ciConfigFile.writeAsStringSync('''
329331
release:
330-
batch: false
332+
batch: true
331333
''');
332334

335+
gitProcessRunner.mockProcessesForExecutable['git-diff'] =
336+
<FakeProcessInfo>[
337+
FakeProcessInfo(MockProcess(stdout: '''
338+
packages/package/CHANGELOG.md
339+
packages/package/pubspec.yaml
340+
''')),
341+
];
342+
gitProcessRunner.mockProcessesForExecutable['git-show'] =
343+
<FakeProcessInfo>[
344+
FakeProcessInfo(MockProcess(stdout: 'version: 1.0.0')),
345+
];
346+
333347
final List<String> output = await runCapturingPrint(runner, <String>[
334348
'version-check',
335349
'--base-sha=main',
@@ -346,7 +360,7 @@ release:
346360
});
347361

348362
test(
349-
'fails for batch release package with no new changelog and post-release label',
363+
'fails for batch release package with no new changelog',
350364
() async {
351365
final RepositoryPackage package =
352366
createFakePackage('package', packagesDir, version: '1.0.0');
@@ -375,7 +389,6 @@ release:
375389
'version-check',
376390
'--base-sha=main',
377391
'--check-for-missing-changes',
378-
'--pr-labels=post-release-package',
379392
], errorHandler: (Error e) {
380393
commandError = e;
381394
});

0 commit comments

Comments
 (0)