diff --git a/common/changes/@microsoft/rush/git-filter-fixes_2024-12-14-00-09.json b/common/changes/@microsoft/rush/git-filter-fixes_2024-12-14-00-09.json new file mode 100644 index 00000000000..34e8460eab0 --- /dev/null +++ b/common/changes/@microsoft/rush/git-filter-fixes_2024-12-14-00-09.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Fix an issue with the `enableSubpathScan` experiment where the set of returned hashes would result in incorrect build cache identifiers when using `--only`.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts index f182b9173ba..4bc5acf7319 100644 --- a/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts +++ b/libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts @@ -556,7 +556,12 @@ export class PhasedScriptAction extends BaseScriptAction { const analyzer: ProjectChangeAnalyzer = new ProjectChangeAnalyzer(this.rushConfiguration); const getInputsSnapshotAsync: GetInputsSnapshotAsyncFn | undefined = - await analyzer._tryGetSnapshotProviderAsync(projectConfigurations, terminal, projectSelection); + await analyzer._tryGetSnapshotProviderAsync( + projectConfigurations, + terminal, + // We need to include all dependencies, otherwise build cache id calculation will be incorrect + Selection.expandAllDependencies(projectSelection) + ); const initialSnapshot: IInputsSnapshot | undefined = await getInputsSnapshotAsync?.(); repoStateStopwatch.stop(); diff --git a/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts b/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts index 5916d0db0c3..a2adc060d5b 100644 --- a/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts +++ b/libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts @@ -296,9 +296,10 @@ export class ProjectChangeAnalyzer { if ( projectSelection && + projectSelection.size > 0 && this._rushConfiguration.experimentsConfiguration.configuration.enableSubpathScan ) { - filterPath = Array.from(projectSelection).map(({ projectFolder }) => projectFolder); + filterPath = Array.from(projectSelection, ({ projectFolder }) => projectFolder); } return async function tryGetSnapshotAsync(): Promise {