From 0a0cce749140a1fc908f699744ce23acaae9b001 Mon Sep 17 00:00:00 2001 From: David Michon Date: Thu, 20 Apr 2023 15:54:21 -0700 Subject: [PATCH] [rush] Fix rush version `workspace:*` perf --- ...-version-workspace-perf_2023-04-20-22-52.json | 10 ++++++++++ libraries/rush-lib/src/logic/PublishUtilities.ts | 16 +++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 common/changes/@microsoft/rush/rush-version-workspace-perf_2023-04-20-22-52.json diff --git a/common/changes/@microsoft/rush/rush-version-workspace-perf_2023-04-20-22-52.json b/common/changes/@microsoft/rush/rush-version-workspace-perf_2023-04-20-22-52.json new file mode 100644 index 00000000000..03f7218f366 --- /dev/null +++ b/common/changes/@microsoft/rush/rush-version-workspace-perf_2023-04-20-22-52.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix a performance bug in `rush version` when using `workspace:` protocol.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/logic/PublishUtilities.ts b/libraries/rush-lib/src/logic/PublishUtilities.ts index 356a5d27647..a6fa6dffd20 100644 --- a/libraries/rush-lib/src/logic/PublishUtilities.ts +++ b/libraries/rush-lib/src/logic/PublishUtilities.ts @@ -779,14 +779,16 @@ export class PublishUtilities { const isWorkspaceWildcardVersion: boolean = requiredVersion.specifierType === DependencySpecifierType.Workspace && requiredVersion.versionSpecifier === '*'; - const alwaysUpdate: boolean = - (!!prereleaseToken && - prereleaseToken.hasValue && - !allChanges.packageChanges.has(parentPackageName)) || - isWorkspaceWildcardVersion; + + const isPrerelease: boolean = + !!prereleaseToken && prereleaseToken.hasValue && !allChanges.packageChanges.has(parentPackageName); // If the version range exists and has not yet been updated to this version, update it. - if (requiredVersion.versionSpecifier !== change.newRangeDependency || alwaysUpdate) { + if ( + isPrerelease || + isWorkspaceWildcardVersion || + requiredVersion.versionSpecifier !== change.newRangeDependency + ) { let changeType: ChangeType | undefined; // Propagate hotfix changes to dependencies if (change.changeType === ChangeType.hotfix) { @@ -815,7 +817,7 @@ export class PublishUtilities { projectsToExclude }); - if (hasChanges || alwaysUpdate) { + if (hasChanges || isPrerelease) { // Only re-evaluate downstream dependencies if updating the parent package's dependency // caused a version bump. hasChanges =