Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updateDependentsVersions disabled with packages still mentioned in changelogs #719

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/melos/lib/src/commands/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,15 @@ mixin _VersionMixin on _RunMixin {
return;
}

final pendingPackageUpdatesCount = updateDependentsVersions
? pendingPackageUpdates.length
: pendingPackageUpdates
.where((update) => update.reason != PackageUpdateReason.dependency)
.length;
mzdm marked this conversation as resolved.
Show resolved Hide resolved
logger.log(
AnsiStyles.magentaBright(
'The following '
'${packageNameStyle(pendingPackageUpdates.length.toString())} '
'${packageNameStyle(pendingPackageUpdatesCount.toString())} '
'packages will be updated:\n',
),
);
Expand Down Expand Up @@ -699,6 +704,7 @@ mixin _VersionMixin on _RunMixin {
workspace,
changelogConfig,
pendingPackageUpdates,
updateDependentsVersions: updateDependentsVersions,
);
}),
);
Expand All @@ -708,8 +714,9 @@ mixin _VersionMixin on _RunMixin {
Future<void> _writeAggregateChangelog(
MelosWorkspace workspace,
AggregateChangelogConfig config,
List<MelosPendingPackageUpdate> pendingPackageUpdates,
) async {
List<MelosPendingPackageUpdate> pendingPackageUpdates, {
required bool updateDependentsVersions,
}) async {
final today = DateTime.now();
final dateSlug = [
today.year.toString(),
Expand All @@ -731,6 +738,7 @@ mixin _VersionMixin on _RunMixin {
pendingPackageUpdates,
logger,
config.path,
updateDependentsVersions: updateDependentsVersions,
);

await changelog.write();
Expand Down
21 changes: 15 additions & 6 deletions packages/melos/lib/src/common/aggregate_changelog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ class AggregateChangelog {
this.newEntryTitle,
this.pendingPackageUpdates,
this.logger,
this.path,
);
this.path, {
required this.updateDependentsVersions,
});

final MelosWorkspace workspace;
final String? description;
final String newEntryTitle;
final MelosLogger logger;
final List<MelosPendingPackageUpdate> pendingPackageUpdates;
final String path;
final bool updateDependentsVersions;

String get _changelogFileHeader => '''
# Change Log
Expand All @@ -44,14 +46,21 @@ ${description?.withoutTrailing('\n') ?? ''}

String get markdown {
final body = StringBuffer();
final dependencyOnlyPackages = pendingPackageUpdates
.where((update) => update.reason == PackageUpdateReason.dependency);
final dependencyOnlyPackages = updateDependentsVersions
? pendingPackageUpdates
.where((update) => update.reason == PackageUpdateReason.dependency)
: <MelosPendingPackageUpdate>[];
final graduatedPackages = pendingPackageUpdates
.where((update) => update.reason == PackageUpdateReason.graduate);
final packagesWithBreakingChanges =
pendingPackageUpdates.where((update) => update.hasBreakingChanges);
final packagesWithOtherChanges =
pendingPackageUpdates.where((update) => !update.hasBreakingChanges);
final packagesWithOtherChanges = pendingPackageUpdates.where((update) {
if (update.reason == PackageUpdateReason.dependency &&
!updateDependentsVersions) {
return false;
}
return !update.hasBreakingChanges;
});

body.writeln(_changelogFileHeader);
body.writeln('## $newEntryTitle');
Expand Down
Loading