From d445a4dce49c35242a83a7e17d514045c992231c Mon Sep 17 00:00:00 2001 From: Cheng Liu Date: Thu, 11 Jul 2024 14:19:06 -0700 Subject: [PATCH 1/3] feat: setup git configurations when full clone --- apps/sparo-lib/src/cli/commands/clone.ts | 59 +++++++++++++----------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/apps/sparo-lib/src/cli/commands/clone.ts b/apps/sparo-lib/src/cli/commands/clone.ts index f81d01d3..d63fa3bf 100644 --- a/apps/sparo-lib/src/cli/commands/clone.ts +++ b/apps/sparo-lib/src/cli/commands/clone.ts @@ -77,16 +77,17 @@ export class CloneCommand implements ICommand { directory: directory }; + const { full, skipGitConfig } = args; + terminal.writeLine('Initializing working directory...'); const stopwatch: Stopwatch = Stopwatch.start(); - if (args.full) { + if (full) { this._gitCloneService.fullClone(cloneOptions); - return; + } else { + this._gitCloneService.bloblessClone(cloneOptions); } - this._gitCloneService.bloblessClone(cloneOptions); - process.chdir(directory); const { profiles, isNoProfile } = await this._sparoProfileService.preprocessProfileArgs({ @@ -94,37 +95,39 @@ export class CloneCommand implements ICommand { addProfilesFromArg: [] }); - await this._GitSparseCheckoutService.ensureSkeletonExistAndUpdated(); + if (!full) { + this._GitSparseCheckoutService.ensureSkeletonExistAndUpdated(); + + // check whether profile exist in local branch + if (!isNoProfile) { + const targetProfileNames: Set = new Set(profiles); + const nonExistProfileNames: string[] = []; + for (const targetProfileName of targetProfileNames) { + if (!this._sparoProfileService.hasProfileInFS(targetProfileName)) { + nonExistProfileNames.push(targetProfileName); + } + } - // check whether profile exist in local branch - if (!isNoProfile) { - const targetProfileNames: Set = new Set(profiles); - const nonExistProfileNames: string[] = []; - for (const targetProfileName of targetProfileNames) { - if (!this._sparoProfileService.hasProfileInFS(targetProfileName)) { - nonExistProfileNames.push(targetProfileName); + if (nonExistProfileNames.length) { + throw new Error( + `Clone failed. The following profile(s) are missing in cloned repo: ${Array.from( + targetProfileNames + ).join(', ')}` + ); } } - if (nonExistProfileNames.length) { - throw new Error( - `Clone failed. The following profile(s) are missing in cloned repo: ${Array.from( - targetProfileNames - ).join(', ')}` - ); + // Avoid redundant sync if no profile is given + if (!isNoProfile && profiles.size) { + // sync local sparse checkout state with given profiles. + await this._sparoProfileService.syncProfileState({ + profiles: isNoProfile ? undefined : profiles + }); } } - // Avoid redundant sync if no profile is given - if (!isNoProfile && profiles.size) { - // sync local sparse checkout state with given profiles. - await this._sparoProfileService.syncProfileState({ - profiles: isNoProfile ? undefined : profiles - }); - } - // set recommended git config - if (!args.skipGitConfig) { + if (!skipGitConfig) { terminal.writeLine(`Applying recommended configuration...`); this._gitService.setRecommendConfig({ overwrite: true }); } @@ -139,7 +142,7 @@ export class CloneCommand implements ICommand { terminal.writeLine(' ' + Colorize.cyan(`cd ${directory}`)); terminal.writeLine(); - if (isNoProfile || profiles.size === 0) { + if (!full && (isNoProfile || profiles.size === 0)) { terminal.writeLine('Your next step is to choose a Sparo profile for checkout.'); terminal.writeLine('To see available profiles in this repo:'); terminal.writeLine(' ' + Colorize.cyan('sparo list-profiles')); From 783f193125afd5a9dc33ee325571a33cb4829c32 Mon Sep 17 00:00:00 2001 From: Cheng Liu Date: Thu, 11 Jul 2024 14:24:32 -0700 Subject: [PATCH 2/3] chore: rush change --- .../sparo/feat-clone-full_2024-07-11-21-24.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/sparo/feat-clone-full_2024-07-11-21-24.json diff --git a/common/changes/sparo/feat-clone-full_2024-07-11-21-24.json b/common/changes/sparo/feat-clone-full_2024-07-11-21-24.json new file mode 100644 index 00000000..62420fbb --- /dev/null +++ b/common/changes/sparo/feat-clone-full_2024-07-11-21-24.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "sparo", + "comment": "Automatically set up recommended git configuration even when full clone", + "type": "none" + } + ], + "packageName": "sparo" +} \ No newline at end of file From 9a005fc25cf53a1995a33e4d1d69eb71a3f1dbc6 Mon Sep 17 00:00:00 2001 From: Cheng Liu Date: Thu, 11 Jul 2024 15:44:39 -0700 Subject: [PATCH 3/3] Update common/changes/sparo/feat-clone-full_2024-07-11-21-24.json Co-authored-by: Pete Gonzalez <4673363+octogonz@users.noreply.github.com> --- common/changes/sparo/feat-clone-full_2024-07-11-21-24.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/changes/sparo/feat-clone-full_2024-07-11-21-24.json b/common/changes/sparo/feat-clone-full_2024-07-11-21-24.json index 62420fbb..87241f59 100644 --- a/common/changes/sparo/feat-clone-full_2024-07-11-21-24.json +++ b/common/changes/sparo/feat-clone-full_2024-07-11-21-24.json @@ -2,7 +2,7 @@ "changes": [ { "packageName": "sparo", - "comment": "Automatically set up recommended git configuration even when full clone", + "comment": "Automatically set up recommended git configuration even when performing a full clone", "type": "none" } ],