Ver código fonte

Prettiers

main
Eric Amodio 5 anos atrás
pai
commit
88a05efb69
25 arquivos alterados com 150 adições e 93 exclusões
  1. +4
    -1
      src/commands/diffDirectory.ts
  2. +9
    -5
      src/commands/git/fetch.ts
  3. +9
    -5
      src/commands/git/pull.ts
  4. +9
    -5
      src/commands/git/push.ts
  5. +9
    -5
      src/commands/git/switch.ts
  6. +4
    -1
      src/commands/git/tag.ts
  7. +2
    -1
      src/extension.ts
  8. +28
    -10
      src/git/gitService.ts
  9. +1
    -1
      src/git/remotes/factory.ts
  10. +4
    -7
      src/keyboard.ts
  11. +2
    -1
      src/quickpicks/branchHistoryQuickPick.ts
  12. +2
    -1
      src/quickpicks/fileHistoryQuickPick.ts
  13. +2
    -1
      src/quickpicks/remotesQuickPick.ts
  14. +14
    -20
      src/system/array.ts
  15. +1
    -3
      src/views/nodes/branchNode.ts
  16. +8
    -2
      src/views/nodes/compareBranchNode.ts
  17. +8
    -2
      src/views/nodes/compareResultsNode.ts
  18. +3
    -1
      src/views/nodes/lineHistoryNode.ts
  19. +4
    -2
      src/views/nodes/lineHistoryTrackerNode.ts
  20. +1
    -3
      src/views/nodes/reflogNode.ts
  21. +4
    -4
      src/views/nodes/reflogRecordNode.ts
  22. +7
    -8
      src/views/nodes/resultsCommitsNode.ts
  23. +7
    -1
      src/views/nodes/statusFilesNode.ts
  24. +1
    -1
      src/views/nodes/tagNode.ts
  25. +7
    -2
      src/views/searchView.ts

+ 4
- 1
src/commands/diffDirectory.ts Ver arquivo

@ -74,7 +74,10 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
if (!args.ref1) {
const pick = await new ReferencesQuickPick(repoPath).show(
`Compare Working Tree with${GlyphChars.Ellipsis}`,
{ allowEnteringRefs: true, checkmarks: false }
{
allowEnteringRefs: true,
checkmarks: false
}
);
if (pick === undefined) return undefined;

+ 9
- 5
src/commands/git/fetch.ts Ver arquivo

@ -79,11 +79,15 @@ export class FetchGitCommand extends QuickCommandBase {
placeholder: 'Choose repositories',
items: await Promise.all(
repos.map(repo =>
RepositoryQuickPickItem.create(repo, actives.some(r => r.id === repo.id), {
branch: true,
fetched: true,
status: true
})
RepositoryQuickPickItem.create(
repo,
actives.some(r => r.id === repo.id),
{
branch: true,
fetched: true,
status: true
}
)
)
)
});

+ 9
- 5
src/commands/git/pull.ts Ver arquivo

@ -89,11 +89,15 @@ export class PullGitCommand extends QuickCommandBase {
placeholder: 'Choose repositories',
items: await Promise.all(
repos.map(repo =>
RepositoryQuickPickItem.create(repo, actives.some(r => r.id === repo.id), {
branch: true,
fetched: true,
status: true
})
RepositoryQuickPickItem.create(
repo,
actives.some(r => r.id === repo.id),
{
branch: true,
fetched: true,
status: true
}
)
)
)
});

+ 9
- 5
src/commands/git/push.ts Ver arquivo

@ -78,11 +78,15 @@ export class PushGitCommand extends QuickCommandBase {
placeholder: 'Choose repositories',
items: await Promise.all(
repos.map(repo =>
RepositoryQuickPickItem.create(repo, actives.some(r => r.id === repo.id), {
branch: true,
fetched: true,
status: true
})
RepositoryQuickPickItem.create(
repo,
actives.some(r => r.id === repo.id),
{
branch: true,
fetched: true,
status: true
}
)
)
)
});

+ 9
- 5
src/commands/git/switch.ts Ver arquivo

@ -113,11 +113,15 @@ export class SwitchGitCommand extends QuickCommandBase {
placeholder: 'Choose repositories',
items: await Promise.all(
repos.map(repo =>
RepositoryQuickPickItem.create(repo, actives.some(r => r.id === repo.id), {
branch: true,
fetched: true,
status: true
})
RepositoryQuickPickItem.create(
repo,
actives.some(r => r.id === repo.id),
{
branch: true,
fetched: true,
status: true
}
)
)
)
});

+ 4
- 1
src/commands/git/tag.ts Ver arquivo

@ -46,7 +46,10 @@ interface DeleteState {
type State = CreateState | DeleteState;
type StashStepState<T> = StepState<T> & { repo: Repository };
const subcommandToTitleMap = new Map<State['subcommand'], string>([['create', 'Create'], ['delete', 'Delete']]);
const subcommandToTitleMap = new Map<State['subcommand'], string>([
['create', 'Create'],
['delete', 'Delete']
]);
function getTitle(title: string, subcommand: State['subcommand'] | undefined) {
return subcommand == null ? title : `${subcommandToTitleMap.get(subcommand)} ${title}`;
}

+ 2
- 1
src/extension.ts Ver arquivo

@ -173,7 +173,8 @@ async function showWelcomeOrWhatsNew(version: string, previousVersion: string |
if (
(major === prevMajor && minor === prevMinor) ||
// Don't notify on downgrades
(major < prevMajor || (major === prevMajor && minor < prevMinor))
major < prevMajor ||
(major === prevMajor && minor < prevMinor)
) {
return;
}

+ 28
- 10
src/git/gitService.ts Ver arquivo

@ -1501,7 +1501,10 @@ export class GitService implements Disposable {
}
}
private getLogMoreFn(log: GitLog, options: { authors?: string[]; limit?: number; merges?: boolean; ref?: string; reverse?: boolean }): (limit: number | { until: string } | undefined) => Promise<GitLog> {
private getLogMoreFn(
log: GitLog,
options: { authors?: string[]; limit?: number; merges?: boolean; ref?: string; reverse?: boolean }
): (limit: number | { until: string } | undefined) => Promise<GitLog> {
return async (limit: number | { until: string } | undefined) => {
const moreUntil = limit != null && typeof limit === 'object' ? limit.until : undefined;
let moreLimit = typeof limit === 'number' ? limit : undefined;
@ -1635,7 +1638,8 @@ export class GitService implements Disposable {
);
if (log !== undefined) {
log.query = (limit: number | undefined) => this.getLogForSearch(repoPath, search, { ...options, limit: limit });
log.query = (limit: number | undefined) =>
this.getLogForSearch(repoPath, search, { ...options, limit: limit });
if (log.hasMore) {
log.more = this.getLogForSearchMoreFn(log, search, options);
}
@ -1647,7 +1651,11 @@ export class GitService implements Disposable {
}
}
private getLogForSearchMoreFn(log: GitLog, search: SearchPattern, options: { limit?: number }): (limit: number | undefined) => Promise<GitLog> {
private getLogForSearchMoreFn(
log: GitLog,
search: SearchPattern,
options: { limit?: number }
): (limit: number | undefined) => Promise<GitLog> {
return async (limit: number | undefined) => {
limit = limit ?? Container.config.advanced.maxSearchItems ?? 0;
@ -1670,7 +1678,8 @@ export class GitService implements Disposable {
count: log.count + moreLog.count,
limit: (log.limit ?? 0) + limit,
hasMore: moreLog.hasMore,
query: (limit: number | undefined) => this.getLogForSearch(log.repoPath, search, { ...options, limit: limit })
query: (limit: number | undefined) =>
this.getLogForSearch(log.repoPath, search, { ...options, limit: limit })
};
mergedLog.more = this.getLogForSearchMoreFn(mergedLog, search, options);
@ -1843,7 +1852,8 @@ export class GitService implements Disposable {
if (log !== undefined) {
const opts = { ...options, ref: ref, range: range };
log.query = (limit: number | undefined) => this.getLogForFile(repoPath, fileName, { ...opts, limit: limit });
log.query = (limit: number | undefined) =>
this.getLogForFile(repoPath, fileName, { ...opts, limit: limit });
if (log.hasMore) {
log.more = this.getLogForFileMoreFn(log, fileName, opts);
}
@ -1869,7 +1879,11 @@ export class GitService implements Disposable {
}
}
private getLogForFileMoreFn(log: GitLog, fileName: string, options: { limit?: number; range?: Range; ref?: string; renames?: boolean; reverse?: boolean }): (limit: number | { until: string } | undefined) => Promise<GitLog> {
private getLogForFileMoreFn(
log: GitLog,
fileName: string,
options: { limit?: number; range?: Range; ref?: string; renames?: boolean; reverse?: boolean }
): (limit: number | { until: string } | undefined) => Promise<GitLog> {
return async (limit: number | { until: string } | undefined) => {
const moreUntil = limit != null && typeof limit === 'object' ? limit.until : undefined;
let moreLimit = typeof limit === 'number' ? limit : undefined;
@ -1900,7 +1914,8 @@ export class GitService implements Disposable {
count: log.count + moreLog.count,
limit: moreUntil == null ? (log.limit ?? 0) + moreLimit : undefined,
hasMore: moreUntil == null ? moreLog.hasMore : true,
query: (limit: number | undefined) => this.getLogForFile(log.repoPath, fileName, { ...options, limit: limit })
query: (limit: number | undefined) =>
this.getLogForFile(log.repoPath, fileName, { ...options, limit: limit })
};
mergedLog.more = this.getLogForFileMoreFn(mergedLog, fileName, options);
@ -2308,7 +2323,7 @@ export class GitService implements Disposable {
const data = await Git.reflog(repoPath, { ...options, limit: limit * 100 });
if (data === undefined) return undefined;
const reflog = GitReflogParser.parse( data, repoPath, reflogCommands, limit, limit * 100);
const reflog = GitReflogParser.parse(data, repoPath, reflogCommands, limit, limit * 100);
if (reflog?.hasMore) {
reflog.more = this.getReflogMoreFn(reflog, options);
}
@ -2320,7 +2335,10 @@ export class GitService implements Disposable {
}
}
private getReflogMoreFn(reflog: GitReflog, options: { all?: boolean; branch?: string; limit?: number; skip?: number }): (limit: number) => Promise<GitReflog> {
private getReflogMoreFn(
reflog: GitReflog,
options: { all?: boolean; branch?: string; limit?: number; skip?: number }
): (limit: number) => Promise<GitReflog> {
return async (limit: number | undefined) => {
limit = limit ?? Container.config.advanced.maxSearchItems ?? 0;
@ -2340,7 +2358,7 @@ export class GitService implements Disposable {
count: reflog.count + moreLog.count,
total: reflog.total + moreLog.total,
limit: (reflog.limit ?? 0) + limit,
hasMore: moreLog.hasMore,
hasMore: moreLog.hasMore
};
mergedLog.more = this.getReflogMoreFn(mergedLog, options);

+ 1
- 1
src/git/remotes/factory.ts Ver arquivo

@ -10,7 +10,7 @@ import { GitLabRemote } from './gitlab';
import { RemoteProvider } from './provider';
export { RemoteProvider };
export type RemoteProviders = [string | RegExp, ((domain: string, path: string) => RemoteProvider)][];
export type RemoteProviders = [string | RegExp, (domain: string, path: string) => RemoteProvider][];
const defaultProviders: RemoteProviders = [
['bitbucket.org', (domain: string, path: string) => new BitbucketRemote(domain, path)],

+ 4
- 7
src/keyboard.ts Ver arquivo

@ -95,13 +95,10 @@ export class KeyboardScope implements Disposable {
if (this._paused) return;
this._paused = true;
const mapping = (Object.keys(this._mapping) as Keys[]).reduce(
(accumulator, key) => {
accumulator[key] = keys === undefined ? false : keys.includes(key) ? false : this._mapping[key];
return accumulator;
},
{} as any
);
const mapping = (Object.keys(this._mapping) as Keys[]).reduce((accumulator, key) => {
accumulator[key] = keys === undefined ? false : keys.includes(key) ? false : this._mapping[key];
return accumulator;
}, {} as any);
await this.updateKeyCommandsContext(mapping);
}

+ 2
- 1
src/quickpicks/branchHistoryQuickPick.ts Ver arquivo

@ -32,7 +32,8 @@ export class BranchHistoryQuickPick {
): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
const items = Array.from(Iterables.map(log.commits.values(), c => CommitQuickPickItem.create(c))) as (
| CommitQuickPickItem
| CommandQuickPickItem)[];
| CommandQuickPickItem
)[];
const currentCommandArgs: ShowQuickBranchHistoryCommandArgs = {
branch: branch,

+ 2
- 1
src/quickpicks/fileHistoryQuickPick.ts Ver arquivo

@ -43,7 +43,8 @@ export class FileHistoryQuickPick {
const items = Array.from(Iterables.map(log.commits.values(), c => CommitQuickPickItem.create(c))) as (
| CommitQuickPickItem
| CommandQuickPickItem)[];
| CommandQuickPickItem
)[];
let index = 0;

+ 2
- 1
src/quickpicks/remotesQuickPick.ts Ver arquivo

@ -152,7 +152,8 @@ export class RemotesQuickPick {
): Promise<OpenRemoteCommandQuickPickItem | CommandQuickPickItem | undefined> {
const items = remotes.map(r => new OpenRemoteCommandQuickPickItem(r, resource, clipboard)) as (
| OpenRemoteCommandQuickPickItem
| CommandQuickPickItem)[];
| CommandQuickPickItem
)[];
if (goBackCommand) {
items.splice(0, 0, goBackCommand);

+ 14
- 20
src/system/array.ts Ver arquivo

@ -15,32 +15,26 @@ export namespace Arrays {
source: T[],
predicateMapper: (item: T) => TMapped | null | undefined
): TMapped[] {
return source.reduce(
(accumulator, current) => {
const mapped = predicateMapper(current);
if (mapped != null) {
accumulator.push(mapped);
}
return accumulator;
},
[] as TMapped[]
);
return source.reduce((accumulator, current) => {
const mapped = predicateMapper(current);
if (mapped != null) {
accumulator.push(mapped);
}
return accumulator;
}, [] as TMapped[]);
}
export function filterMapAsync<T, TMapped>(
source: T[],
predicateMapper: (item: T) => Promise<TMapped | null | undefined>
): Promise<TMapped[]> {
return source.reduce(
async (accumulator, current) => {
const mapped = await predicateMapper(current);
if (mapped != null) {
accumulator.push(mapped);
}
return accumulator;
},
[] as any
);
return source.reduce(async (accumulator, current) => {
const mapped = await predicateMapper(current);
if (mapped != null) {
accumulator.push(mapped);
}
return accumulator;
}, [] as any);
}
export function groupBy<T>(source: T[], accessor: (item: T) => string): { [key: string]: T[] } {

+ 1
- 3
src/views/nodes/branchNode.ts Ver arquivo

@ -101,9 +101,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
);
if (log.hasMore) {
children.push(
new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1])
);
children.push(new ShowMoreNode(this.view, this, 'Commits', children[children.length - 1]));
}
this._children = children;

+ 8
- 2
src/views/nodes/compareBranchNode.ts Ver arquivo

@ -198,7 +198,10 @@ export class CompareBranchNode extends ViewNode {
const count = log?.count ?? 0;
const results: Mutable<Partial<CommitsQueryResults>> = {
label: Strings.pluralize('commit', count, { number: log?.hasMore ?? false ? `${count}+` : undefined, zero: 'No' }),
label: Strings.pluralize('commit', count, {
number: log?.hasMore ?? false ? `${count}+` : undefined,
zero: 'No'
}),
log: log,
hasMore: log?.hasMore ?? true
};
@ -207,7 +210,10 @@ export class CompareBranchNode extends ViewNode {
results.log = (await results.log?.more?.(limit)) ?? results.log;
const count = results.log?.count ?? 0;
results.label = Strings.pluralize('commit', count, { number: results.log?.hasMore ?? false ? `${count}+` : undefined, zero: 'No' });
results.label = Strings.pluralize('commit', count, {
number: results.log?.hasMore ?? false ? `${count}+` : undefined,
zero: 'No'
});
results.hasMore = results.log?.hasMore ?? true;
};
}

+ 8
- 2
src/views/nodes/compareResultsNode.ts Ver arquivo

@ -209,7 +209,10 @@ export class CompareResultsNode extends SubscribeableViewNode {
const count = log?.count ?? 0;
const results: Mutable<Partial<CommitsQueryResults>> = {
label: Strings.pluralize('commit', count, { number: log?.hasMore ?? false ? `${count}+` : undefined, zero: 'No' }),
label: Strings.pluralize('commit', count, {
number: log?.hasMore ?? false ? `${count}+` : undefined,
zero: 'No'
}),
log: log,
hasMore: log?.hasMore ?? true
};
@ -218,7 +221,10 @@ export class CompareResultsNode extends SubscribeableViewNode {
results.log = (await results.log?.more?.(limit)) ?? results.log;
const count = results.log?.count ?? 0;
results.label = Strings.pluralize('commit', count, { number: results.log?.hasMore ?? false ? `${count}+` : undefined, zero: 'No' });
results.label = Strings.pluralize('commit', count, {
number: results.log?.hasMore ?? false ? `${count}+` : undefined,
zero: 'No'
});
results.hasMore = results.log?.hasMore ?? true;
};
}

+ 3
- 1
src/views/nodes/lineHistoryNode.ts Ver arquivo

@ -22,7 +22,9 @@ import { RepositoryNode } from './repositoryNode';
export class LineHistoryNode extends SubscribeableViewNode implements PageableViewNode {
static key = ':history:line';
static getId(repoPath: string, uri: string, selection: Selection): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${uri}[${selection.start.line},${selection.start.character}-${selection.end.line},${selection.end.character}])`;
return `${RepositoryNode.getId(repoPath)}${this.key}(${uri}[${selection.start.line},${
selection.start.character
}-${selection.end.line},${selection.end.character}])`;
}
constructor(

+ 4
- 2
src/views/nodes/lineHistoryTrackerNode.ts Ver arquivo

@ -127,7 +127,8 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
if (
editor.document.uri.path === this.uri.path &&
(this._selection !== undefined && editor.selection.isEqual(this._selection))
this._selection !== undefined &&
editor.selection.isEqual(this._selection)
) {
if (cc !== undefined) {
cc.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
@ -140,7 +141,8 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
if (
this.uri !== unknownGitUri &&
UriComparer.equals(gitUri, this.uri) &&
(this._selection !== undefined && editor.selection.isEqual(this._selection))
this._selection !== undefined &&
editor.selection.isEqual(this._selection)
) {
return true;
}

+ 1
- 3
src/views/nodes/reflogNode.ts Ver arquivo

@ -37,9 +37,7 @@ export class ReflogNode extends ViewNode implements PageableVi
children.push(...reflog.records.map(r => new ReflogRecordNode(this.view, this, r)));
if (reflog.hasMore) {
children.push(
new ShowMoreNode(this.view, this, 'Activity', children[children.length - 1])
);
children.push(new ShowMoreNode(this.view, this, 'Activity', children[children.length - 1]));
}
this._children = children;

+ 4
- 4
src/views/nodes/reflogRecordNode.ts Ver arquivo

@ -63,15 +63,15 @@ export class ReflogRecordNode extends ViewNode implements Pageabl
this.record.HEAD.length === 0
? ''
: `${this.record.HEAD} ${GlyphChars.Space}${GlyphChars.Dot}${GlyphChars.Space} `
}${this.record.formattedDate}`;
}${this.record.formattedDate}`;
item.contextValue = ResourceType.ReflogRecord;
item.tooltip = `${this.record.HEAD.length === 0 ? '' : `${this.record.HEAD}\n`}${this.record.command}${
this.record.commandArgs ? ` ${this.record.commandArgs}` : ''
}${
}${
this.record.details ? ` (${this.record.details})` : ''
}\n${this.record.formatDateFromNow()} (${this.record.formatDate()})\n${this.record.previousShortSha} ${
}\n${this.record.formatDateFromNow()} (${this.record.formatDate()})\n${this.record.previousShortSha} ${
GlyphChars.Space
}${GlyphChars.ArrowRight}${GlyphChars.Space} ${this.record.shortSha}`;
}${GlyphChars.ArrowRight}${GlyphChars.Space} ${this.record.shortSha}`;
return item;
}

+ 7
- 8
src/views/nodes/resultsCommitsNode.ts Ver arquivo

@ -58,9 +58,7 @@ export class ResultsCommitsNode extends ViewNode implements Pagea
];
if (log.hasMore) {
children.push(
new ShowMoreNode(this.view, this, 'Results', children[children.length - 1])
);
children.push(new ShowMoreNode(this.view, this, 'Results', children[children.length - 1]));
}
return children;
@ -73,11 +71,12 @@ export class ResultsCommitsNode extends ViewNode implements Pagea
try {
({ label, log } = await Promises.timeout(this.getCommitsQueryResults(), 100));
state = log == null || log.count === 0
? TreeItemCollapsibleState.None
: this._options.expand || log.count === 1
? TreeItemCollapsibleState.Expanded
: TreeItemCollapsibleState.Collapsed;
state =
log == null || log.count === 0
? TreeItemCollapsibleState.None
: this._options.expand || log.count === 1
? TreeItemCollapsibleState.Expanded
: TreeItemCollapsibleState.Collapsed;
} catch (ex) {
if (ex instanceof Promises.TimeoutError) {
ex.promise.then(() => this.triggerChange(false));

+ 7
- 1
src/views/nodes/statusFilesNode.ts Ver arquivo

@ -93,7 +93,13 @@ export class StatusFilesNode extends ViewNode {
...Iterables.map(
Objects.values(groups),
files =>
new StatusFileNode(this.view, this, repoPath, files[files.length - 1], files.map(s => s.commit))
new StatusFileNode(
this.view,
this,
repoPath,
files[files.length - 1],
files.map(s => s.commit)
)
)
];

+ 1
- 1
src/views/nodes/tagNode.ts Ver arquivo

@ -97,7 +97,7 @@ export class TagNode extends ViewRefNode implements PageableVi
limit: this.limit ?? this.view.config.defaultItemLimit,
ref: this.tag.name
});
}
}
return this._log;
}

+ 7
- 2
src/views/searchView.ts Ver arquivo

@ -175,9 +175,14 @@ export class SearchView extends ViewBase {
};
}
const searchQueryFn = Functions.cachedOnce(this.getSearchQueryFn(log, { label: label, ...options }), results as SearchQueryResults);
const searchQueryFn = Functions.cachedOnce(
this.getSearchQueryFn(log, { label: label, ...options }),
results as SearchQueryResults
);
return this.addResults(new SearchResultsCommitsNode(this, this._root!, repoPath, search, labelString, searchQueryFn));
return this.addResults(
new SearchResultsCommitsNode(this, this._root!, repoPath, search, labelString, searchQueryFn)
);
}
private addResults(results: ViewNode) {

||||||
x
 
000:0
Carregando…
Cancelar
Salvar