瀏覽代碼

Adds push repositories command

Adds @command decorator
Changes (fetch|pull|push)All to be cancelable
main
Eric Amodio 6 年之前
父節點
當前提交
9a1b48af19
共有 54 個檔案被更改,包括 390 行新增327 行删除
  1. +18
    -0
      package.json
  2. +4
    -108
      src/commands.ts
  3. +123
    -0
      src/commands/annotations.ts
  4. +0
    -34
      src/commands/clearFileAnnotations.ts
  5. +2
    -1
      src/commands/closeUnchangedFiles.ts
  6. +20
    -0
      src/commands/common.ts
  7. +9
    -1
      src/commands/copyMessageToClipboard.ts
  8. +2
    -0
      src/commands/copyRemoteFileUrlToClipboard.ts
  9. +9
    -1
      src/commands/copyShaToClipboard.ts
  10. +9
    -1
      src/commands/diffBranchWithBranch.ts
  11. +2
    -0
      src/commands/diffDirectory.ts
  12. +3
    -2
      src/commands/diffLineWithPrevious.ts
  13. +3
    -2
      src/commands/diffLineWithWorking.ts
  14. +2
    -1
      src/commands/diffWith.ts
  15. +2
    -1
      src/commands/diffWithBranch.ts
  16. +3
    -2
      src/commands/diffWithNext.ts
  17. +6
    -3
      src/commands/diffWithPrevious.ts
  18. +2
    -1
      src/commands/diffWithRevision.ts
  19. +2
    -1
      src/commands/diffWithWorking.ts
  20. +31
    -34
      src/commands/externalDiff.ts
  21. +0
    -13
      src/commands/fetchRepositories.ts
  22. +2
    -0
      src/commands/openBranchInRemote.ts
  23. +2
    -0
      src/commands/openBranchesInRemote.ts
  24. +2
    -1
      src/commands/openChangedFiles.ts
  25. +9
    -1
      src/commands/openCommitInRemote.ts
  26. +2
    -0
      src/commands/openFileInRemote.ts
  27. +2
    -1
      src/commands/openFileRevision.ts
  28. +2
    -1
      src/commands/openInRemote.ts
  29. +2
    -0
      src/commands/openRepoInRemote.ts
  30. +2
    -1
      src/commands/openWorkingFile.ts
  31. +0
    -13
      src/commands/pullRepositories.ts
  32. +36
    -0
      src/commands/repositories.ts
  33. +2
    -1
      src/commands/resetSuppressedWarnings.ts
  34. +3
    -2
      src/commands/showCommitSearch.ts
  35. +2
    -1
      src/commands/showLastQuickPick.ts
  36. +2
    -1
      src/commands/showQuickBranchHistory.ts
  37. +2
    -0
      src/commands/showQuickCommitDetails.ts
  38. +2
    -0
      src/commands/showQuickCommitFileDetails.ts
  39. +2
    -1
      src/commands/showQuickCurrentBranchHistory.ts
  40. +2
    -1
      src/commands/showQuickFileHistory.ts
  41. +2
    -1
      src/commands/showQuickRepoStatus.ts
  42. +2
    -1
      src/commands/showQuickStashList.ts
  43. +2
    -1
      src/commands/showView.ts
  44. +2
    -0
      src/commands/stashApply.ts
  45. +2
    -1
      src/commands/stashDelete.ts
  46. +2
    -0
      src/commands/stashSave.ts
  47. +4
    -1
      src/commands/switchMode.ts
  48. +2
    -1
      src/commands/toggleCodeLens.ts
  49. +0
    -49
      src/commands/toggleFileBlame.ts
  50. +0
    -17
      src/commands/toggleFileHeatmap.ts
  51. +0
    -17
      src/commands/toggleFileRecentChanges.ts
  52. +2
    -1
      src/commands/toggleLineBlame.ts
  53. +2
    -2
      src/extension.ts
  54. +38
    -4
      src/git/gitService.ts

+ 18
- 0
package.json 查看文件

@ -1914,6 +1914,15 @@
}
},
{
"command": "gitlens.pushRepositories",
"title": "Push Repositories",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-push.svg",
"light": "images/light/icon-push.svg"
}
},
{
"command": "gitlens.views.fetch",
"title": "Fetch Repository",
"category": "GitLens",
@ -2595,6 +2604,10 @@
"when": "gitlens:hasRemotes"
},
{
"command": "gitlens.pushRepositories",
"when": "gitlens:hasRemotes"
},
{
"command": "gitlens.views.fetch",
"when": "false"
},
@ -3112,6 +3125,11 @@
"group": "navigation@1"
},
{
"command": "gitlens.pushRepositories",
"when": "gitlens:enabled && view =~ /^gitlens.views.repositories:/",
"group": "navigation@6"
},
{
"command": "gitlens.pullRepositories",
"when": "gitlens:enabled && view =~ /^gitlens.views.repositories:/",
"group": "navigation@7"

+ 4
- 108
src/commands.ts 查看文件

@ -1,57 +1,8 @@
'use strict';
import { ClearFileAnnotationsCommand } from './commands/clearFileAnnotations';
import { CloseUnchangedFilesCommand } from './commands/closeUnchangedFiles';
import { CopyMessageToClipboardCommand } from './commands/copyMessageToClipboard';
import { CopyRemoteFileUrlToClipboardCommand } from './commands/copyRemoteFileUrlToClipboard';
import { CopyShaToClipboardCommand } from './commands/copyShaToClipboard';
import { DiffBranchWithBranchCommand } from './commands/diffBranchWithBranch';
import { DiffDirectoryCommand } from './commands/diffDirectory';
import { DiffLineWithPreviousCommand } from './commands/diffLineWithPrevious';
import { DiffLineWithWorkingCommand } from './commands/diffLineWithWorking';
import { DiffWithCommand } from './commands/diffWith';
import { DiffWithBranchCommand } from './commands/diffWithBranch';
import { DiffWithNextCommand } from './commands/diffWithNext';
import { DiffWithPreviousCommand } from './commands/diffWithPrevious';
import { DiffWithRevisionCommand } from './commands/diffWithRevision';
import { DiffWithWorkingCommand } from './commands/diffWithWorking';
import { ExternalDiffCommand } from './commands/externalDiff';
import { FetchRepositoriesCommand } from './commands/fetchRepositories';
import { OpenBranchesInRemoteCommand } from './commands/openBranchesInRemote';
import { OpenBranchInRemoteCommand } from './commands/openBranchInRemote';
import { OpenChangedFilesCommand } from './commands/openChangedFiles';
import { OpenCommitInRemoteCommand } from './commands/openCommitInRemote';
import { OpenFileInRemoteCommand } from './commands/openFileInRemote';
import { OpenFileRevisionCommand } from './commands/openFileRevision';
import { OpenInRemoteCommand } from './commands/openInRemote';
import { OpenRepoInRemoteCommand } from './commands/openRepoInRemote';
import { OpenWorkingFileCommand } from './commands/openWorkingFile';
import { PullRepositoriesCommand } from './commands/pullRepositories';
import { ResetSuppressedWarningsCommand } from './commands/resetSuppressedWarnings';
import { ShowCommitSearchCommand } from './commands/showCommitSearch';
import { ShowLastQuickPickCommand } from './commands/showLastQuickPick';
import { ShowQuickBranchHistoryCommand } from './commands/showQuickBranchHistory';
import { ShowQuickCommitDetailsCommand } from './commands/showQuickCommitDetails';
import { ShowQuickCommitFileDetailsCommand } from './commands/showQuickCommitFileDetails';
import { ShowQuickCurrentBranchHistoryCommand } from './commands/showQuickCurrentBranchHistory';
import { ShowQuickFileHistoryCommand } from './commands/showQuickFileHistory';
import { ShowQuickRepoStatusCommand } from './commands/showQuickRepoStatus';
import { ShowQuickStashListCommand } from './commands/showQuickStashList';
import { ShowViewCommand } from './commands/showView';
import { StashApplyCommand } from './commands/stashApply';
import { StashDeleteCommand } from './commands/stashDelete';
import { StashSaveCommand } from './commands/stashSave';
import { SwitchModeCommand, ToggleReviewModeCommand, ToggleZenModeCommand } from './commands/switchMode';
import { ToggleCodeLensCommand } from './commands/toggleCodeLens';
import { ToggleFileBlameCommand } from './commands/toggleFileBlame';
import { ToggleFileHeatmapCommand } from './commands/toggleFileHeatmap';
import { ToggleFileRecentChangesCommand } from './commands/toggleFileRecentChanges';
import { ToggleLineBlameCommand } from './commands/toggleLineBlame';
import { CommandContext, setCommandContext } from './constants';
import { Container } from './container';
export * from './commands/common';
export * from './commands/clearFileAnnotations';
export * from './commands/annotations';
export * from './commands/closeUnchangedFiles';
export * from './commands/common';
export * from './commands/copyMessageToClipboard';
export * from './commands/copyRemoteFileUrlToClipboard';
export * from './commands/copyShaToClipboard';
@ -75,9 +26,9 @@ export * from './commands/openFileRevision';
export * from './commands/openInRemote';
export * from './commands/openRepoInRemote';
export * from './commands/openWorkingFile';
export * from './commands/repositories';
export * from './commands/resetSuppressedWarnings';
export * from './commands/showCommitSearch';
export * from './commands/showView';
export * from './commands/showLastQuickPick';
export * from './commands/showQuickBranchHistory';
export * from './commands/showQuickCommitDetails';
@ -86,64 +37,9 @@ export * from './commands/showQuickCurrentBranchHistory';
export * from './commands/showQuickFileHistory';
export * from './commands/showQuickRepoStatus';
export * from './commands/showQuickStashList';
export * from './commands/showView';
export * from './commands/stashApply';
export * from './commands/stashDelete';
export * from './commands/stashSave';
export * from './commands/switchMode';
export * from './commands/toggleCodeLens';
export * from './commands/toggleFileBlame';
export * from './commands/toggleFileHeatmap';
export * from './commands/toggleFileRecentChanges';
export * from './commands/toggleLineBlame';
export function configureCommands(): void {
Container.context.subscriptions.push(new ClearFileAnnotationsCommand());
Container.context.subscriptions.push(new CloseUnchangedFilesCommand());
Container.context.subscriptions.push(new CopyMessageToClipboardCommand());
Container.context.subscriptions.push(new CopyRemoteFileUrlToClipboardCommand());
Container.context.subscriptions.push(new CopyShaToClipboardCommand());
Container.context.subscriptions.push(new DiffBranchWithBranchCommand());
Container.context.subscriptions.push(new DiffDirectoryCommand());
Container.context.subscriptions.push(new DiffLineWithPreviousCommand());
Container.context.subscriptions.push(new DiffLineWithWorkingCommand());
Container.context.subscriptions.push(new DiffWithCommand());
Container.context.subscriptions.push(new DiffWithBranchCommand());
Container.context.subscriptions.push(new DiffWithNextCommand());
Container.context.subscriptions.push(new DiffWithPreviousCommand());
Container.context.subscriptions.push(new DiffWithRevisionCommand());
Container.context.subscriptions.push(new DiffWithWorkingCommand());
Container.context.subscriptions.push(new ExternalDiffCommand());
Container.context.subscriptions.push(new FetchRepositoriesCommand());
Container.context.subscriptions.push(new OpenBranchesInRemoteCommand());
Container.context.subscriptions.push(new OpenBranchInRemoteCommand());
Container.context.subscriptions.push(new OpenChangedFilesCommand());
Container.context.subscriptions.push(new OpenCommitInRemoteCommand());
Container.context.subscriptions.push(new OpenFileInRemoteCommand());
Container.context.subscriptions.push(new OpenFileRevisionCommand());
Container.context.subscriptions.push(new OpenInRemoteCommand());
Container.context.subscriptions.push(new OpenRepoInRemoteCommand());
Container.context.subscriptions.push(new OpenWorkingFileCommand());
Container.context.subscriptions.push(new PullRepositoriesCommand());
Container.context.subscriptions.push(new ResetSuppressedWarningsCommand());
Container.context.subscriptions.push(new ShowCommitSearchCommand());
Container.context.subscriptions.push(new ShowViewCommand());
Container.context.subscriptions.push(new ShowLastQuickPickCommand());
Container.context.subscriptions.push(new ShowQuickBranchHistoryCommand());
Container.context.subscriptions.push(new ShowQuickCommitDetailsCommand());
Container.context.subscriptions.push(new ShowQuickCommitFileDetailsCommand());
Container.context.subscriptions.push(new ShowQuickCurrentBranchHistoryCommand());
Container.context.subscriptions.push(new ShowQuickFileHistoryCommand());
Container.context.subscriptions.push(new ShowQuickRepoStatusCommand());
Container.context.subscriptions.push(new ShowQuickStashListCommand());
Container.context.subscriptions.push(new StashApplyCommand());
Container.context.subscriptions.push(new StashDeleteCommand());
Container.context.subscriptions.push(new StashSaveCommand());
Container.context.subscriptions.push(new SwitchModeCommand());
Container.context.subscriptions.push(new ToggleCodeLensCommand());
Container.context.subscriptions.push(new ToggleFileBlameCommand());
Container.context.subscriptions.push(new ToggleFileHeatmapCommand());
Container.context.subscriptions.push(new ToggleFileRecentChangesCommand());
Container.context.subscriptions.push(new ToggleLineBlameCommand());
Container.context.subscriptions.push(new ToggleReviewModeCommand());
Container.context.subscriptions.push(new ToggleZenModeCommand());
}

+ 123
- 0
src/commands/annotations.ts 查看文件

@ -0,0 +1,123 @@
'use strict';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { UriComparer } from '../comparers';
import { FileAnnotationType } from '../configuration';
import { isTextEditor } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, command, Commands, EditorCommand } from './common';
@command()
export class ClearFileAnnotationsCommand extends EditorCommand {
constructor() {
super([Commands.ClearFileAnnotations, Commands.ComputingFileAnnotations]);
}
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri): Promise<any> {
// Handle the case where we are focused on a non-editor editor (output, debug console)
if (editor != null && !isTextEditor(editor)) {
if (uri != null && !UriComparer.equals(uri, editor.document.uri)) {
const e = window.visibleTextEditors.find(e => UriComparer.equals(uri, e.document.uri));
if (e !== undefined) {
editor = e;
}
}
}
try {
return Container.fileAnnotations.clear(editor);
}
catch (ex) {
Logger.error(ex, 'ClearFileAnnotationsCommand');
return Messages.showGenericErrorMessage('Unable to clear file annotations');
}
}
}
export interface ToggleFileBlameCommandArgs {
sha?: string;
type?: FileAnnotationType;
}
@command()
export class ToggleFileBlameCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ToggleFileBlame);
}
async execute(editor: TextEditor, uri?: Uri, args: ToggleFileBlameCommandArgs = {}): Promise<any> {
// Handle the case where we are focused on a non-editor editor (output, debug console)
if (editor != null && !isTextEditor(editor)) {
if (uri != null && !UriComparer.equals(uri, editor.document.uri)) {
const e = window.visibleTextEditors.find(e => UriComparer.equals(uri, e.document.uri));
if (e !== undefined) {
editor = e;
}
}
}
try {
if (args.type === undefined) {
args = { ...args, type: FileAnnotationType.Blame };
}
return Container.fileAnnotations.toggle(
editor,
args.type!,
args.sha !== undefined ? args.sha : editor && editor.selection.active.line
);
}
catch (ex) {
Logger.error(ex, 'ToggleFileBlameCommand');
return window.showErrorMessage(
`Unable to toggle file ${args.type} annotations. See output channel for more details`
);
}
}
}
@command()
export class ToggleFileHeatmapCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ToggleFileHeatmap);
}
async execute(editor: TextEditor, uri?: Uri): Promise<any> {
commands.executeCommand(Commands.ToggleFileBlame, uri, {
type: FileAnnotationType.Heatmap
} as ToggleFileBlameCommandArgs);
}
}
@command()
export class ToggleFileRecentChangesCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ToggleFileRecentChanges);
}
async execute(editor: TextEditor, uri?: Uri): Promise<any> {
commands.executeCommand(Commands.ToggleFileBlame, uri, {
type: FileAnnotationType.RecentChanges
} as ToggleFileBlameCommandArgs);
}
}
@command()
export class ToggleLineBlameCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ToggleLineBlame);
}
async execute(editor: TextEditor, uri?: Uri): Promise<any> {
try {
return Container.lineAnnotations.toggle(editor);
}
catch (ex) {
Logger.error(ex, 'ToggleLineBlameCommand');
return window.showErrorMessage(
`Unable to toggle line blame annotations. See output channel for more details`
);
}
}
}

+ 0
- 34
src/commands/clearFileAnnotations.ts 查看文件

@ -1,34 +0,0 @@
'use strict';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { UriComparer } from '../comparers';
import { isTextEditor } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Commands, EditorCommand } from './common';
export class ClearFileAnnotationsCommand extends EditorCommand {
constructor() {
super([Commands.ClearFileAnnotations, Commands.ComputingFileAnnotations]);
}
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri): Promise<any> {
// Handle the case where we are focused on a non-editor editor (output, debug console)
if (editor != null && !isTextEditor(editor)) {
if (uri != null && !UriComparer.equals(uri, editor.document.uri)) {
const e = window.visibleTextEditors.find(e => UriComparer.equals(uri, e.document.uri));
if (e !== undefined) {
editor = e;
}
}
}
try {
return Container.fileAnnotations.clear(editor);
}
catch (ex) {
Logger.error(ex, 'ClearFileAnnotationsCommand');
return Messages.showGenericErrorMessage('Unable to clear file annotations');
}
}
}

+ 2
- 1
src/commands/closeUnchangedFiles.ts 查看文件

@ -6,12 +6,13 @@ import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Functions } from '../system';
import { ActiveEditorCommand, Commands, getCommandUri, getRepoPathOrPrompt } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri, getRepoPathOrPrompt } from './common';
export interface CloseUnchangedFilesCommandArgs {
uris?: Uri[];
}
@command()
export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
private _onEditorChangedFn: ((editor: TextEditor | undefined) => void) | undefined;

+ 20
- 0
src/commands/common.ts 查看文件

@ -3,6 +3,7 @@ import * as paths from 'path';
import {
commands,
Disposable,
ExtensionContext,
SourceControlResourceGroup,
SourceControlResourceState,
TextDocumentShowOptions,
@ -53,6 +54,7 @@ export enum Commands {
OpenRepoInRemote = 'gitlens.openRepoInRemote',
OpenWorkingFile = 'gitlens.openWorkingFile',
PullRepositories = 'gitlens.pullRepositories',
PushRepositories = 'gitlens.pushRepositories',
ResetSuppressedWarnings = 'gitlens.resetSuppressedWarnings',
ShowCommitInResults = 'gitlens.showCommitInResults',
ShowCommitSearch = 'gitlens.showCommitSearch',
@ -87,6 +89,24 @@ export enum Commands {
ViewsOpenDirectoryDiffWithWorking = 'gitlens.views.openDirectoryDiffWithWorking'
}
interface CommandConstructor {
new (): any;
}
const registrableCommands: CommandConstructor[] = [];
export function command(): ClassDecorator {
return (target: any) => {
registrableCommands.push(target);
};
}
export function registerCommands(context: ExtensionContext): void {
for (const c of registrableCommands) {
context.subscriptions.push(new c());
}
}
export function getCommandUri(uri?: Uri, editor?: TextEditor): Uri | undefined {
if (uri instanceof Uri) return uri;
if (editor == null) return undefined;

+ 9
- 1
src/commands/copyMessageToClipboard.ts 查看文件

@ -6,13 +6,21 @@ import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
isCommandViewContextWithCommit
} from './common';
export interface CopyMessageToClipboardCommandArgs {
message?: string;
sha?: string;
}
@command()
export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
constructor() {
super(Commands.CopyMessageToClipboard);

+ 2
- 0
src/commands/copyRemoteFileUrlToClipboard.ts 查看文件

@ -2,6 +2,7 @@
import { commands, TextEditor, Uri } from 'vscode';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
isCommandViewContextWithBranch,
@ -13,6 +14,7 @@ export interface CopyRemoteFileUrlToClipboardCommandArgs {
range?: boolean;
}
@command()
export class CopyRemoteFileUrlToClipboardCommand extends ActiveEditorCommand {
constructor() {
super(Commands.CopyRemoteFileUrlToClipboard);

+ 9
- 1
src/commands/copyShaToClipboard.ts 查看文件

@ -6,12 +6,20 @@ import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
isCommandViewContextWithCommit
} from './common';
export interface CopyShaToClipboardCommandArgs {
sha?: string;
}
@command()
export class CopyShaToClipboardCommand extends ActiveEditorCommand {
constructor() {
super(Commands.CopyShaToClipboard);

+ 9
- 1
src/commands/diffBranchWithBranch.ts 查看文件

@ -5,13 +5,21 @@ import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
getRepoPathOrActiveOrPrompt
} from './common';
export interface DiffBranchWithBranchCommandArgs {
ref1?: string;
ref2?: string;
}
@command()
export class DiffBranchWithBranchCommand extends ActiveEditorCommand {
constructor() {
super([Commands.DiffHeadWithBranch, Commands.DiffWorkingWithBranch]);

+ 2
- 0
src/commands/diffDirectory.ts 查看文件

@ -8,6 +8,7 @@ import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { ResultsComparisonNode } from '../views/nodes';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
@ -20,6 +21,7 @@ export interface DiffDirectoryCommandArgs {
ref2?: string;
}
@command()
export class DiffDirectoryCommand extends ActiveEditorCommand {
constructor() {
super([Commands.DiffDirectory, Commands.ViewsOpenDirectoryDiff, Commands.ViewsOpenDirectoryDiffWithWorking]);

+ 3
- 2
src/commands/diffLineWithPrevious.ts 查看文件

@ -1,10 +1,10 @@
'use strict';
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { commands, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitCommit, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffLineWithPreviousCommandArgs {
@ -14,6 +14,7 @@ export interface DiffLineWithPreviousCommandArgs {
showOptions?: TextDocumentShowOptions;
}
@command()
export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
constructor() {
super(Commands.DiffLineWithPrevious);

+ 3
- 2
src/commands/diffLineWithWorking.ts 查看文件

@ -1,10 +1,10 @@
'use strict';
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { commands, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitCommit, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffLineWithWorkingCommandArgs {
@ -14,6 +14,7 @@ export interface DiffLineWithWorkingCommandArgs {
showOptions?: TextDocumentShowOptions;
}
@command()
export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
constructor() {
super(Commands.DiffLineWithWorking);

+ 2
- 1
src/commands/diffWith.ts 查看文件

@ -6,7 +6,7 @@ import { Container } from '../container';
import { GitCommit, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, Commands } from './common';
import { ActiveEditorCommand, command, Commands } from './common';
export interface DiffWithCommandArgsRevision {
sha: string;
@ -23,6 +23,7 @@ export interface DiffWithCommandArgs {
showOptions?: TextDocumentShowOptions;
}
@command()
export class DiffWithCommand extends ActiveEditorCommand {
static getMarkdownCommandArgs(args: DiffWithCommandArgs): string;
static getMarkdownCommandArgs(commit1: GitCommit, commit2: GitCommit): string;

+ 2
- 1
src/commands/diffWithBranch.ts 查看文件

@ -7,7 +7,7 @@ import { GitUri } from '../git/gitService';
import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { Strings } from '../system';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithBranchCommandArgs {
@ -17,6 +17,7 @@ export interface DiffWithBranchCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class DiffWithBranchCommand extends ActiveEditorCommand {
constructor() {
super(Commands.DiffWithBranch);

+ 3
- 2
src/commands/diffWithNext.ts 查看文件

@ -1,11 +1,11 @@
'use strict';
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitLogCommit, GitService, GitStatusFile, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithNextCommandArgs {
@ -16,6 +16,7 @@ export interface DiffWithNextCommandArgs {
showOptions?: TextDocumentShowOptions;
}
@command()
export class DiffWithNextCommand extends ActiveEditorCommand {
constructor() {
super(Commands.DiffWithNext);

+ 6
- 3
src/commands/diffWithPrevious.ts 查看文件

@ -1,11 +1,11 @@
'use strict';
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { commands, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitCommit, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri } from './common';
import { ActiveEditorCommand, command, CommandContext, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith';
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
@ -17,6 +17,7 @@ export interface DiffWithPreviousCommandArgs {
showOptions?: TextDocumentShowOptions;
}
@command()
export class DiffWithPreviousCommand extends ActiveEditorCommand {
constructor() {
super([Commands.DiffWithPrevious, Commands.DiffWithPreviousInDiff]);
@ -44,7 +45,9 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
try {
let sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
if (sha === GitService.deletedOrMissingSha) return Messages.showCommitHasNoPreviousCommitWarningMessage();
if (sha === GitService.deletedOrMissingSha) {
return Messages.showCommitHasNoPreviousCommitWarningMessage();
}
// If we are a fake "staged" sha, remove it
let isStagedUncommitted = false;

+ 2
- 1
src/commands/diffWithRevision.ts 查看文件

@ -7,7 +7,7 @@ import { Logger } from '../logger';
import { Messages } from '../messages';
import { ChooseFromBranchesAndTagsQuickPickItem, CommandQuickPickItem, FileHistoryQuickPick } from '../quickpicks';
import { Iterables, Strings } from '../system';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithRevisionCommandArgs {
@ -19,6 +19,7 @@ export interface DiffWithRevisionCommandArgs {
nextPageCommand?: CommandQuickPickItem;
}
@command()
export class DiffWithRevisionCommand extends ActiveEditorCommand {
constructor() {
super(Commands.DiffWithRevision);

+ 2
- 1
src/commands/diffWithWorking.ts 查看文件

@ -4,7 +4,7 @@ import { Container } from '../container';
import { GitCommit, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithWorkingCommandArgs {
@ -14,6 +14,7 @@ export interface DiffWithWorkingCommandArgs {
showOptions?: TextDocumentShowOptions;
}
@command()
export class DiffWithWorkingCommand extends ActiveEditorCommand {
constructor() {
super(Commands.DiffWithWorking);

+ 31
- 34
src/commands/externalDiff.ts 查看文件

@ -7,6 +7,7 @@ import { Logger } from '../logger';
import { Messages } from '../messages';
import { Arrays } from '../system';
import {
command,
Command,
CommandContext,
Commands,
@ -47,19 +48,18 @@ interface Resource extends SourceControlResourceState {
readonly type: Status;
}
class ExternalDiffFile {
constructor(
public readonly uri: Uri,
public readonly staged: boolean,
public readonly ref1?: string,
public readonly ref2?: string
) {}
interface ExternalDiffFile {
uri: Uri;
staged: boolean;
ref1?: string;
ref2?: string;
}
export interface ExternalDiffCommandArgs {
files?: ExternalDiffFile[];
}
@command()
export class ExternalDiffCommand extends Command {
constructor() {
super([Commands.ExternalDiff, Commands.ExternalDiffAll]);
@ -75,12 +75,12 @@ export class ExternalDiffCommand extends Command {
const ref2 = context.node.commit.isUncommitted ? '' : context.node.commit.sha;
args.files = [
new ExternalDiffFile(
GitUri.fromFile(context.node.file, context.node.file.repoPath || context.node.repoPath),
context.node.commit.isStagedUncommitted || context.node.file.indexStatus !== undefined,
ref1,
ref2
)
{
uri: GitUri.fromFile(context.node.file, context.node.file.repoPath || context.node.repoPath),
staged: context.node.commit.isStagedUncommitted || context.node.file.indexStatus !== undefined,
ref1: ref1,
ref2: ref2
}
];
return this.execute(args);
@ -90,12 +90,12 @@ export class ExternalDiffCommand extends Command {
args = { ...args };
args.files = [
new ExternalDiffFile(
GitUri.fromFile(context.node.file, context.node.file.repoPath || context.node.repoPath),
context.node.file.indexStatus !== undefined,
context.node.ref1,
context.node.ref2
)
{
uri: GitUri.fromFile(context.node.file, context.node.file.repoPath || context.node.repoPath),
staged: context.node.file.indexStatus !== undefined,
ref1: context.node.ref1,
ref2: context.node.ref2
}
];
return this.execute(args);
@ -104,13 +104,10 @@ export class ExternalDiffCommand extends Command {
if (args.files === undefined) {
if (context.type === 'scm-states') {
args = { ...args };
args.files = context.scmResourceStates.map(
r =>
new ExternalDiffFile(
r.resourceUri,
(r as Resource).resourceGroupType === ResourceGroupType.Index
)
);
args.files = context.scmResourceStates.map(r => ({
uri: r.resourceUri,
staged: (r as Resource).resourceGroupType === ResourceGroupType.Index
}));
}
else if (context.type === 'scm-groups') {
args = { ...args };
@ -118,10 +115,10 @@ export class ExternalDiffCommand extends Command {
context.scmResourceGroups[0].resourceStates,
r =>
this.isModified(r)
? new ExternalDiffFile(
r.resourceUri,
(r as Resource).resourceGroupType === ResourceGroupType.Index
)
? {
uri: r.resourceUri,
staged: (r as Resource).resourceGroupType === ResourceGroupType.Index
}
: undefined
);
}
@ -144,11 +141,11 @@ export class ExternalDiffCommand extends Command {
for (const file of status.files) {
if (file.indexStatus === 'M') {
args.files.push(new ExternalDiffFile(file.uri, true));
args.files.push({ uri: file.uri, staged: true });
}
if (file.workingTreeStatus === 'M') {
args.files.push(new ExternalDiffFile(file.uri, false));
args.files.push({ uri: file.uri, staged: false });
}
}
}
@ -180,11 +177,11 @@ export class ExternalDiffCommand extends Command {
args.files = [];
if (status.indexStatus === 'M') {
args.files.push(new ExternalDiffFile(status.uri, true));
args.files.push({ uri: status.uri, staged: true });
}
if (status.workingTreeStatus === 'M') {
args.files.push(new ExternalDiffFile(status.uri, false));
args.files.push({ uri: status.uri, staged: false });
}
}
else {

+ 0
- 13
src/commands/fetchRepositories.ts 查看文件

@ -1,13 +0,0 @@
'use strict';
import { Container } from '../container';
import { Command, Commands } from './common';
export class FetchRepositoriesCommand extends Command {
constructor() {
super(Commands.FetchRepositories);
}
async execute() {
return Container.git.fetchAll();
}
}

+ 2
- 0
src/commands/openBranchInRemote.ts 查看文件

@ -7,6 +7,7 @@ import { Logger } from '../logger';
import { BranchesQuickPick, CommandQuickPickItem } from '../quickpicks';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
@ -20,6 +21,7 @@ export interface OpenBranchInRemoteCommandArgs {
remote?: string;
}
@command()
export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
constructor() {
super(Commands.OpenBranchInRemote);

+ 2
- 0
src/commands/openBranchesInRemote.ts 查看文件

@ -6,6 +6,7 @@ import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
@ -18,6 +19,7 @@ export interface OpenBranchesInRemoteCommandArgs {
remote?: string;
}
@command()
export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
constructor() {
super(Commands.OpenBranchesInRemote);

+ 2
- 1
src/commands/openChangedFiles.ts 查看文件

@ -5,12 +5,13 @@ import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Arrays } from '../system';
import { ActiveEditorCommand, Commands, getCommandUri, getRepoPathOrPrompt, openEditor } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri, getRepoPathOrPrompt, openEditor } from './common';
export interface OpenChangedFilesCommandArgs {
uris?: Uri[];
}
@command()
export class OpenChangedFilesCommand extends ActiveEditorCommand {
constructor() {
super(Commands.OpenChangedFiles);

+ 9
- 1
src/commands/openCommitInRemote.ts 查看文件

@ -4,13 +4,21 @@ import { Container } from '../container';
import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
isCommandViewContextWithCommit
} from './common';
import { OpenInRemoteCommandArgs } from './openInRemote';
export interface OpenCommitInRemoteCommandArgs {
sha?: string;
}
@command()
export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
static getMarkdownCommandArgs(sha: string): string;
static getMarkdownCommandArgs(args: OpenCommitInRemoteCommandArgs): string;

+ 2
- 0
src/commands/openFileInRemote.ts 查看文件

@ -7,6 +7,7 @@ import { Logger } from '../logger';
import { BranchesQuickPick, CommandQuickPickItem } from '../quickpicks';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
@ -21,6 +22,7 @@ export interface OpenFileInRemoteCommandArgs {
clipboard?: boolean;
}
@command()
export class OpenFileInRemoteCommand extends ActiveEditorCommand {
constructor() {
super(Commands.OpenFileInRemote);

+ 2
- 1
src/commands/openFileRevision.ts 查看文件

@ -8,7 +8,7 @@ import { Logger } from '../logger';
import { Messages } from '../messages';
import { ChooseFromBranchesAndTagsQuickPickItem, CommandQuickPickItem, FileHistoryQuickPick } from '../quickpicks';
import { Iterables, Strings } from '../system';
import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri, openEditor } from './common';
export interface OpenFileRevisionCommandArgs {
branchOrTag?: GitBranch | GitTag;
@ -21,6 +21,7 @@ export interface OpenFileRevisionCommandArgs {
nextPageCommand?: CommandQuickPickItem;
}
@command()
export class OpenFileRevisionCommand extends ActiveEditorCommand {
static getMarkdownCommandArgs(args: OpenFileRevisionCommandArgs): string;
static getMarkdownCommandArgs(uri: Uri, annotationType?: FileAnnotationType, line?: number): string;

+ 2
- 1
src/commands/openInRemote.ts 查看文件

@ -6,7 +6,7 @@ import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickpicks';
import { Strings } from '../system';
import { ActiveEditorCommand, Commands } from './common';
import { ActiveEditorCommand, command, Commands } from './common';
export interface OpenInRemoteCommandArgs {
remote?: string;
@ -17,6 +17,7 @@ export interface OpenInRemoteCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class OpenInRemoteCommand extends ActiveEditorCommand {
constructor() {
super(Commands.OpenInRemote);

+ 2
- 0
src/commands/openRepoInRemote.ts 查看文件

@ -6,6 +6,7 @@ import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
@ -18,6 +19,7 @@ export interface OpenRepoInRemoteCommandArgs {
remote?: string;
}
@command()
export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
constructor() {
super(Commands.OpenRepoInRemote);

+ 2
- 1
src/commands/openWorkingFile.ts 查看文件

@ -6,7 +6,7 @@ import { Container } from '../container';
import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common';
import { ActiveEditorCommand, command, Commands, getCommandUri, openEditor } from './common';
export interface OpenWorkingFileCommandArgs {
uri?: Uri;
@ -15,6 +15,7 @@ export interface OpenWorkingFileCommandArgs {
annotationType?: FileAnnotationType;
}
@command()
export class OpenWorkingFileCommand extends ActiveEditorCommand {
constructor() {
super(Commands.OpenWorkingFile);

+ 0
- 13
src/commands/pullRepositories.ts 查看文件

@ -1,13 +0,0 @@
'use strict';
import { Container } from '../container';
import { Command, Commands } from './common';
export class PullRepositoriesCommand extends Command {
constructor() {
super(Commands.PullRepositories);
}
async execute() {
return Container.git.pullAll();
}
}

+ 36
- 0
src/commands/repositories.ts 查看文件

@ -0,0 +1,36 @@
'use strict';
import { Container } from '../container';
import { command, Command, Commands } from './common';
@command()
export class FetchRepositoriesCommand extends Command {
constructor() {
super(Commands.FetchRepositories);
}
async execute() {
return Container.git.fetchAll();
}
}
@command()
export class PullRepositoriesCommand extends Command {
constructor() {
super(Commands.PullRepositories);
}
async execute() {
return Container.git.pullAll();
}
}
@command()
export class PushRepositoriesCommand extends Command {
constructor() {
super(Commands.PushRepositories);
}
async execute() {
return Container.git.pushAll();
}
}

+ 2
- 1
src/commands/resetSuppressedWarnings.ts 查看文件

@ -1,8 +1,9 @@
'use strict';
import { ConfigurationTarget } from 'vscode';
import { configuration } from '../configuration';
import { Command, Commands } from './common';
import { command, Command, Commands } from './common';
@command()
export class ResetSuppressedWarningsCommand extends Command {
constructor() {
super(Commands.ResetSuppressedWarnings);

+ 3
- 2
src/commands/showCommitSearch.ts 查看文件

@ -6,10 +6,10 @@ import { GitRepoSearchBy, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, CommitsQuickPick, ShowCommitsSearchInResultsQuickPickItem } from '../quickpicks';
import { Strings } from '../system';
import { Iterables } from '../system/iterable';
import { Iterables, Strings } from '../system';
import {
ActiveEditorCachedCommand,
command,
CommandContext,
Commands,
getCommandUri,
@ -44,6 +44,7 @@ export interface ShowCommitSearchCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
constructor() {
super(Commands.ShowCommitSearch);

+ 2
- 1
src/commands/showLastQuickPick.ts 查看文件

@ -2,8 +2,9 @@
import { commands } from 'vscode';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Command, Commands, getLastCommand } from './common';
import { command, Command, Commands, getLastCommand } from './common';
@command()
export class ShowLastQuickPickCommand extends Command {
constructor() {
super(Commands.ShowLastQuickPick);

+ 2
- 1
src/commands/showQuickBranchHistory.ts 查看文件

@ -7,7 +7,7 @@ import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickpicks';
import { Strings } from '../system';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ActiveEditorCachedCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
export interface ShowQuickBranchHistoryCommandArgs {
@ -20,6 +20,7 @@ export interface ShowQuickBranchHistoryCommandArgs {
nextPageCommand?: CommandQuickPickItem;
}
@command()
export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
constructor() {
super(Commands.ShowQuickBranchHistory);

+ 2
- 0
src/commands/showQuickCommitDetails.ts 查看文件

@ -10,6 +10,7 @@ import { CommandQuickPickItem, CommitQuickPick, CommitWithFileStatusQuickPickIte
import { Strings } from '../system';
import {
ActiveEditorCachedCommand,
command,
CommandContext,
Commands,
getCommandUri,
@ -26,6 +27,7 @@ export interface ShowQuickCommitDetailsCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
static getMarkdownCommandArgs(sha: string): string;
static getMarkdownCommandArgs(args: ShowQuickCommitDetailsCommandArgs): string;

+ 2
- 0
src/commands/showQuickCommitFileDetails.ts 查看文件

@ -10,6 +10,7 @@ import { CommandQuickPickItem, CommitFileQuickPick } from '../quickpicks';
import { Strings } from '../system';
import {
ActiveEditorCachedCommand,
command,
CommandContext,
Commands,
getCommandUri,
@ -25,6 +26,7 @@ export interface ShowQuickCommitFileDetailsCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand {
static getMarkdownCommandArgs(sha: string): string;
static getMarkdownCommandArgs(args: ShowQuickCommitFileDetailsCommandArgs): string;

+ 2
- 1
src/commands/showQuickCurrentBranchHistory.ts 查看文件

@ -5,13 +5,14 @@ import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem } from '../quickpicks';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ActiveEditorCachedCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ShowQuickBranchHistoryCommandArgs } from './showQuickBranchHistory';
export interface ShowQuickCurrentBranchHistoryCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedCommand {
constructor() {
super(Commands.ShowQuickCurrentBranchHistory);

+ 2
- 1
src/commands/showQuickFileHistory.ts 查看文件

@ -13,7 +13,7 @@ import {
ShowCommitsInResultsQuickPickItem
} from '../quickpicks';
import { Iterables, Strings } from '../system';
import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri } from './common';
import { ActiveEditorCachedCommand, command, CommandContext, Commands, getCommandUri } from './common';
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
export interface ShowQuickFileHistoryCommandArgs {
@ -27,6 +27,7 @@ export interface ShowQuickFileHistoryCommandArgs {
nextPageCommand?: CommandQuickPickItem;
}
@command()
export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
constructor() {
super([Commands.ShowFileHistoryInResults, Commands.ShowQuickFileHistory]);

+ 2
- 1
src/commands/showQuickRepoStatus.ts 查看文件

@ -5,12 +5,13 @@ import { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickpicks';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ActiveEditorCachedCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
export interface ShowQuickRepoStatusCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
constructor() {
super(Commands.ShowQuickRepoStatus);

+ 2
- 1
src/commands/showQuickStashList.ts 查看文件

@ -6,13 +6,14 @@ import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, StashListQuickPick } from '../quickpicks';
import { Strings } from '../system';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ActiveEditorCachedCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
export interface ShowQuickStashListCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
constructor() {
super(Commands.ShowQuickStashList);

+ 2
- 1
src/commands/showView.ts 查看文件

@ -1,7 +1,8 @@
'use strict';
import { Container } from '../container';
import { Command, CommandContext, Commands } from './common';
import { command, Command, CommandContext, Commands } from './common';
@command()
export class ShowViewCommand extends Command {
constructor() {
super([

+ 2
- 0
src/commands/stashApply.ts 查看文件

@ -8,6 +8,7 @@ import { Messages } from '../messages';
import { CommandQuickPickItem, StashListQuickPick } from '../quickpicks';
import { Strings } from '../system';
import {
command,
Command,
CommandContext,
Commands,
@ -25,6 +26,7 @@ export interface StashApplyCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class StashApplyCommand extends Command {
constructor() {
super(Commands.StashApply);

+ 2
- 1
src/commands/stashDelete.ts 查看文件

@ -6,7 +6,7 @@ import { GitStashCommit } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem } from '../quickpicks';
import { Command, CommandContext, Commands, isCommandViewContextWithCommit } from './common';
import { command, Command, CommandContext, Commands, isCommandViewContextWithCommit } from './common';
export interface StashDeleteCommandArgs {
confirm?: boolean;
@ -15,6 +15,7 @@ export interface StashDeleteCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class StashDeleteCommand extends Command {
constructor() {
super(Commands.StashDelete);

+ 2
- 0
src/commands/stashSave.ts 查看文件

@ -7,6 +7,7 @@ import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem } from '../quickpicks';
import {
command,
Command,
CommandContext,
Commands,
@ -23,6 +24,7 @@ export interface StashSaveCommandArgs {
goBackCommand?: CommandQuickPickItem;
}
@command()
export class StashSaveCommand extends Command {
constructor() {
super(Commands.StashSave);

+ 4
- 1
src/commands/switchMode.ts 查看文件

@ -3,8 +3,9 @@ import { ConfigurationTarget } from 'vscode';
import { configuration } from '../configuration';
import { Container } from '../container';
import { ModesQuickPick } from '../quickpicks';
import { Command, Commands } from './common';
import { command, Command, Commands } from './common';
@command()
export class SwitchModeCommand extends Command {
constructor() {
super(Commands.SwitchMode);
@ -18,6 +19,7 @@ export class SwitchModeCommand extends Command {
}
}
@command()
export class ToggleReviewModeCommand extends Command {
constructor() {
super(Commands.ToggleReviewMode);
@ -31,6 +33,7 @@ export class ToggleReviewModeCommand extends Command {
}
}
@command()
export class ToggleZenModeCommand extends Command {
constructor() {
super(Commands.ToggleZenMode);

+ 2
- 1
src/commands/toggleCodeLens.ts 查看文件

@ -1,7 +1,8 @@
'use strict';
import { Container } from '../container';
import { Command, Commands } from './common';
import { command, Command, Commands } from './common';
@command()
export class ToggleCodeLensCommand extends Command {
constructor() {
super(Commands.ToggleCodeLens);

+ 0
- 49
src/commands/toggleFileBlame.ts 查看文件

@ -1,49 +0,0 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { UriComparer } from '../comparers';
import { FileAnnotationType } from '../configuration';
import { isTextEditor } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { ActiveEditorCommand, Commands } from './common';
export interface ToggleFileBlameCommandArgs {
sha?: string;
type?: FileAnnotationType;
}
export class ToggleFileBlameCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ToggleFileBlame);
}
async execute(editor: TextEditor, uri?: Uri, args: ToggleFileBlameCommandArgs = {}): Promise<any> {
// Handle the case where we are focused on a non-editor editor (output, debug console)
if (editor != null && !isTextEditor(editor)) {
if (uri != null && !UriComparer.equals(uri, editor.document.uri)) {
const e = window.visibleTextEditors.find(e => UriComparer.equals(uri, e.document.uri));
if (e !== undefined) {
editor = e;
}
}
}
try {
if (args.type === undefined) {
args = { ...args, type: FileAnnotationType.Blame };
}
return Container.fileAnnotations.toggle(
editor,
args.type!,
args.sha !== undefined ? args.sha : editor && editor.selection.active.line
);
}
catch (ex) {
Logger.error(ex, 'ToggleFileBlameCommand');
return window.showErrorMessage(
`Unable to toggle file ${args.type} annotations. See output channel for more details`
);
}
}
}

+ 0
- 17
src/commands/toggleFileHeatmap.ts 查看文件

@ -1,17 +0,0 @@
'use strict';
import { commands, TextEditor, Uri } from 'vscode';
import { FileAnnotationType } from '../configuration';
import { ActiveEditorCommand, Commands } from './common';
import { ToggleFileBlameCommandArgs } from './toggleFileBlame';
export class ToggleFileHeatmapCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ToggleFileHeatmap);
}
async execute(editor: TextEditor, uri?: Uri): Promise<any> {
commands.executeCommand(Commands.ToggleFileBlame, uri, {
type: FileAnnotationType.Heatmap
} as ToggleFileBlameCommandArgs);
}
}

+ 0
- 17
src/commands/toggleFileRecentChanges.ts 查看文件

@ -1,17 +0,0 @@
'use strict';
import { commands, TextEditor, Uri } from 'vscode';
import { FileAnnotationType } from '../configuration';
import { ActiveEditorCommand, Commands } from './common';
import { ToggleFileBlameCommandArgs } from './toggleFileBlame';
export class ToggleFileRecentChangesCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ToggleFileRecentChanges);
}
async execute(editor: TextEditor, uri?: Uri): Promise<any> {
commands.executeCommand(Commands.ToggleFileBlame, uri, {
type: FileAnnotationType.RecentChanges
} as ToggleFileBlameCommandArgs);
}
}

+ 2
- 1
src/commands/toggleLineBlame.ts 查看文件

@ -2,8 +2,9 @@
import { TextEditor, Uri, window } from 'vscode';
import { Container } from '../container';
import { Logger } from '../logger';
import { ActiveEditorCommand, Commands } from './common';
import { ActiveEditorCommand, command, Commands } from './common';
@command()
export class ToggleLineBlameCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ToggleLineBlame);

+ 2
- 2
src/extension.ts 查看文件

@ -1,6 +1,6 @@
'use strict';
import { commands, ExtensionContext, extensions, window, workspace } from 'vscode';
import { Commands, configureCommands } from './commands';
import { Commands, registerCommands } from './commands';
import { Config, configuration, Configuration } from './configuration';
import { CommandContext, extensionQualifiedId, GlobalState, GlyphChars, setCommandContext } from './constants';
import { Container } from './container';
@ -57,7 +57,7 @@ export async function activate(context: ExtensionContext) {
Container.initialize(context, cfg);
configureCommands();
registerCommands(context);
const gitVersion = GitService.getGitVersion();

+ 38
- 4
src/git/gitService.ts 查看文件

@ -480,9 +480,9 @@ export class GitService implements Disposable {
{
location: ProgressLocation.Notification,
title: `Fetching repositories`,
cancellable: false
cancellable: true
},
async progress => {
async (progress, token) => {
const total = repositories.length + 1;
let i = 0;
for (const repo of repositories) {
@ -492,6 +492,8 @@ export class GitService implements Disposable {
increment: (i / total) * 100
});
if (token.isCancellationRequested) break;
await this.fetch(repo.path);
}
}
@ -508,9 +510,9 @@ export class GitService implements Disposable {
{
location: ProgressLocation.Notification,
title: `Pulling repositories`,
cancellable: false
cancellable: true
},
async progress => {
async (progress, token) => {
const total = repositories.length + 1;
let i = 0;
for (const repo of repositories) {
@ -520,12 +522,44 @@ export class GitService implements Disposable {
increment: (i / total) * 100
});
if (token.isCancellationRequested) break;
await repo.pull({ progress: false });
}
}
);
}
@gate()
@log()
async pushAll() {
const repositories = [...(await this.getRepositories())];
if (repositories.length === 0) return;
await window.withProgress(
{
location: ProgressLocation.Notification,
title: `Pushing repositories`,
cancellable: true
},
async (progress, token) => {
const total = repositories.length + 1;
let i = 0;
for (const repo of repositories) {
i++;
progress.report({
message: `${repo.formattedName}...`,
increment: (i / total) * 100
});
if (token.isCancellationRequested) break;
await repo.push({ progress: false });
}
}
);
}
private async fileExists(
repoPath: string,
fileName: string,

Loading…
取消
儲存