Skip to content

Commit

Permalink
Fix oldVersion in modification
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Dec 19, 2023
1 parent 8c6c34b commit c35c08e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/bump_version_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BumpVersionCommand extends Command {

Future<void> applyModifications() async {
for (final modification in _modifications) {
await modification.call(package, version, bumpedVersion);
await modification.call(package, currentVersion, bumpedVersion);
}
}

Expand Down
32 changes: 32 additions & 0 deletions test/add_modification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,36 @@ dependencies:
expect(readme.readAsStringSync(), contains('my_package: ^1.3.0'));
});
});

test('modification receives correct versions', () async {
await insideFakeProjectWithSidekick((dir) async {
await dir.file('pubspec.yaml').appendString('\nversion: 1.2.3');
final readme = dir.file('README.md');
readme.writeAsStringSync('''
# Package
```yaml
dependencies:
my_package: ^1.2.3
```
''');
final runner = initializeSidekick(
dartSdkPath: fakeDartSdk().path,
);

Version? oldVersion;
Version? newVersion;
runner.addCommand(
BumpVersionCommand()
..addModification((package, oldV, newV) {
oldVersion = oldV;
newVersion = newV;
}),
);
await runner.run(['bump-version', '--minor']);

expect(oldVersion, Version(1, 2, 3));
expect(newVersion, Version(1, 3, 0));
});
});
}

0 comments on commit c35c08e

Please sign in to comment.