From f6df534f0202d665d2378b034228bbc9d4ce636c Mon Sep 17 00:00:00 2001 From: Cheng Liu Date: Thu, 9 May 2024 17:44:12 -0700 Subject: [PATCH] fix: dedup temporary selections --- .../src/services/SparoProfileService.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/sparo-lib/src/services/SparoProfileService.ts b/apps/sparo-lib/src/services/SparoProfileService.ts index bbbae27..4446ebf 100644 --- a/apps/sparo-lib/src/services/SparoProfileService.ts +++ b/apps/sparo-lib/src/services/SparoProfileService.ts @@ -344,18 +344,25 @@ ${availableProfiles.join(',')} const fromSelector: Set = fromProjects || new Set(); // If Rush Selector --to is specified, using `git sparse-checkout add` to add folders of the projects specified const projectsSelections: ISelection[] = [...rushSelectorState]; + const existingSelections: Set = new Set( + rushSelectorState.map(({ selector, argument }) => `${selector}$$${argument}`) + ); for (const project of toSelector) { - projectsSelections.push({ - selector: '--to', - argument: project - }); + if (!existingSelections.has(`--to$$${project}`)) { + projectsSelections.push({ + selector: '--to', + argument: project + }); + } } for (const project of fromSelector) { - projectsSelections.push({ - selector: '--from', - argument: project - }); + if (!existingSelections.has(`--from$$${project}`)) { + projectsSelections.push({ + selector: '--from', + argument: project + }); + } } if (projectsSelections.length > 0) {