提交 a308b39f 编写于 作者: J Joao Moreno

clean all paths

fixes #8590
上级 767b11e9
...@@ -257,8 +257,12 @@ export function fill<T>(num: number, valueFn: () => T, arr: T[] = []): T[] { ...@@ -257,8 +257,12 @@ export function fill<T>(num: number, valueFn: () => T, arr: T[] = []): T[] {
return arr; return arr;
} }
export function index<T>(array: T[], indexer: (t: T) => string): { [key: string]: T; } { export function index<T>(array: T[], indexer: (t: T) => string): { [key: string]: T; };
const result = Object.create(null); export function index<T,R>(array: T[], indexer: (t: T) => string, merger?: (t: T, r: R) => R): { [key: string]: R; };
array.forEach(t => result[indexer(t)] = t); export function index<T,R>(array: T[], indexer: (t: T) => string, merger: (t: T, r: R) => R = t => t as any): { [key: string]: R; } {
return result; return array.reduce((r, t) => {
const key = indexer(t);
r[key] = merger(t, r[key]);
return r;
}, Object.create(null));
} }
\ No newline at end of file
...@@ -11,9 +11,10 @@ import * as pfs from 'vs/base/node/pfs'; ...@@ -11,9 +11,10 @@ import * as pfs from 'vs/base/node/pfs';
import { guessMimeTypes, isBinaryMime } from 'vs/base/common/mime'; import { guessMimeTypes, isBinaryMime } from 'vs/base/common/mime';
import { IDisposable, toDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, toDisposable, dispose } from 'vs/base/common/lifecycle';
import { assign } from 'vs/base/common/objects'; import { assign } from 'vs/base/common/objects';
import { sequence } from 'vs/base/common/async';
import { v4 as UUIDv4 } from 'vs/base/common/uuid'; import { v4 as UUIDv4 } from 'vs/base/common/uuid';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { uniqueFilter } from 'vs/base/common/arrays'; import { uniqueFilter, index } from 'vs/base/common/arrays';
import { IRawFileStatus, RefType, IRef, IBranch, IRemote, GitErrorCodes, IPushOptions } from 'vs/workbench/parts/git/common/git'; import { IRawFileStatus, RefType, IRef, IBranch, IRemote, GitErrorCodes, IPushOptions } from 'vs/workbench/parts/git/common/git';
import { detectMimesFromStream } from 'vs/base/node/mime'; import { detectMimesFromStream } from 'vs/base/node/mime';
import { IFileOperationResult, FileOperationResult } from 'vs/platform/files/common/files'; import { IFileOperationResult, FileOperationResult } from 'vs/platform/files/common/files';
...@@ -447,8 +448,11 @@ export class Repository { ...@@ -447,8 +448,11 @@ export class Repository {
} }
clean(paths: string[]): Promise { clean(paths: string[]): Promise {
const args = [ 'clean', '-f', '-q', '--' ].concat(paths); const byDirname = index<string, string[]>(paths, p => path.dirname(p), (p, r) => (r || []).concat([p]));
return this.run(args); const groups = Object.keys(byDirname).map(key => byDirname[key]);
const tasks = groups.map(group => () => this.run([ 'clean', '-f', '-q', '--' ].concat(group)));
return sequence(tasks);
} }
undo(): Promise { undo(): Promise {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册