chore: apply cr suggestion

This commit is contained in:
EscapeB 2024-02-27 16:33:37 +08:00
parent 9fc3cfc60f
commit 02aa23b93b
3 changed files with 6 additions and 18 deletions

View file

@ -173,10 +173,10 @@ export class CheckoutCommand implements ICommand<ICheckoutCommandOptions> {
await this._gitSparseCheckoutService.purgeAsync();
} else if (targetProfileNames.size) {
// TODO: policy #1: Can not sparse checkout with uncommitted changes in the cone.
for (const p of profiles) {
for (const profile of profiles) {
// Since we have run localState.reset() before, for each profile we just add it to local state.
const { selections, includeFolders, excludeFolders } =
await this._gitSparseCheckoutService.resolveSparoProfileAsync(p, {
await this._gitSparseCheckoutService.resolveSparoProfileAsync(profile, {
localStateUpdateAction: 'add'
});
// for profiles, we use sparse checkout set
@ -187,10 +187,10 @@ export class CheckoutCommand implements ICommand<ICheckoutCommandOptions> {
checkoutAction: 'set'
});
}
for (const p of addProfiles) {
for (const profile of addProfiles) {
// For each add profile we add it to local state.
const { selections, includeFolders, excludeFolders } =
await this._gitSparseCheckoutService.resolveSparoProfileAsync(p, {
await this._gitSparseCheckoutService.resolveSparoProfileAsync(profile, {
localStateUpdateAction: 'add'
});
// for add profiles, we use sparse checkout add
@ -287,9 +287,7 @@ export class CheckoutCommand implements ICommand<ICheckoutCommandOptions> {
const addProfiles: Set<string> = new Set(addProfilesFromArg.filter((p) => typeof p === 'string'));
if (isNoProfile && (profiles.size || addProfiles.size)) {
throw new Error(
`The "--no-profile" parameter cannot be combined with "--profile" or "--add-profile"`
);
throw new Error(`The "--no-profile" parameter cannot be combined with "--profile" or "--add-profile"`);
}
return {

View file

@ -237,7 +237,7 @@ ${availableProfiles.join(',')}
terminal.writeDebugLine(`Skip sparse checkout regarding no target folders`);
} else {
terminal.writeLine(
`Performing sparse checkout ${checkoutAction} for these folders: ${targetFolders.join(' ')}`
`Performing sparse checkout ${checkoutAction} for these folders: \n${targetFolders.join('\n ')}`
);
this._sparseCheckoutPaths(targetFolders, {
action: checkoutAction

View file

@ -1,10 +0,0 @@
{
"changes": [
{
"packageName": "sparo",
"comment": "refactor sparo checkout profile logic",
"type": "none"
}
],
"packageName": "sparo"
}