Skip to content

Commit

Permalink
Merge pull request microsoft#4068 from dmichon-msft/rush-version-work…
Browse files Browse the repository at this point in the history
…space-perf

[rush] Fix rush version `workspace:*` perf
  • Loading branch information
dmichon-msft authored Apr 21, 2023
2 parents 63304a8 + 0a0cce7 commit 14f9259
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
16 changes: 9 additions & 7 deletions libraries/rush-lib/src/logic/PublishUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 14f9259

Please sign in to comment.