Skip to content

Commit 4f94865

Browse files
authored
[rush] Fix build cache ids when "enableSubPathScan" is enabled (#5045)
Co-authored-by: David Michon <[email protected]>
1 parent 2e2ac57 commit 4f94865

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Fix an issue with the `enableSubpathScan` experiment where the set of returned hashes would result in incorrect build cache identifiers when using `--only`.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}

libraries/rush-lib/src/cli/scriptActions/PhasedScriptAction.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,12 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> {
556556

557557
const analyzer: ProjectChangeAnalyzer = new ProjectChangeAnalyzer(this.rushConfiguration);
558558
const getInputsSnapshotAsync: GetInputsSnapshotAsyncFn | undefined =
559-
await analyzer._tryGetSnapshotProviderAsync(projectConfigurations, terminal, projectSelection);
559+
await analyzer._tryGetSnapshotProviderAsync(
560+
projectConfigurations,
561+
terminal,
562+
// We need to include all dependencies, otherwise build cache id calculation will be incorrect
563+
Selection.expandAllDependencies(projectSelection)
564+
);
560565
const initialSnapshot: IInputsSnapshot | undefined = await getInputsSnapshotAsync?.();
561566

562567
repoStateStopwatch.stop();

libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,10 @@ export class ProjectChangeAnalyzer {
296296

297297
if (
298298
projectSelection &&
299+
projectSelection.size > 0 &&
299300
this._rushConfiguration.experimentsConfiguration.configuration.enableSubpathScan
300301
) {
301-
filterPath = Array.from(projectSelection).map(({ projectFolder }) => projectFolder);
302+
filterPath = Array.from(projectSelection, ({ projectFolder }) => projectFolder);
302303
}
303304

304305
return async function tryGetSnapshotAsync(): Promise<IInputsSnapshot | undefined> {

0 commit comments

Comments
 (0)