Browse Source

Renames commands/commands to commands/common

Renames quickpicks/quickpicks to quickpicks/common
Moves git quick picks into common and other quick pick files
main
Eric Amodio 7 years ago
parent
commit
8b0748608d
42 changed files with 357 additions and 359 deletions
  1. +2
    -18
      src/commands.ts
  2. +1
    -1
      src/commands/closeUnchangedFiles.ts
  3. +14
    -0
      src/commands/common.ts
  4. +1
    -1
      src/commands/copyMessageToClipboard.ts
  5. +1
    -1
      src/commands/copyShaToClipboard.ts
  6. +1
    -1
      src/commands/diffDirectory.ts
  7. +1
    -1
      src/commands/diffLineWithPrevious.ts
  8. +1
    -1
      src/commands/diffLineWithWorking.ts
  9. +1
    -1
      src/commands/diffWithBranch.ts
  10. +1
    -1
      src/commands/diffWithNext.ts
  11. +1
    -1
      src/commands/diffWithPrevious.ts
  12. +1
    -1
      src/commands/diffWithWorking.ts
  13. +2
    -2
      src/commands/keyboard.ts
  14. +1
    -1
      src/commands/openChangedFiles.ts
  15. +1
    -1
      src/commands/openCommitInRemote.ts
  16. +1
    -1
      src/commands/openFileInRemote.ts
  17. +1
    -1
      src/commands/openInRemote.ts
  18. +1
    -1
      src/commands/showBlame.ts
  19. +1
    -1
      src/commands/showBlameHistory.ts
  20. +1
    -1
      src/commands/showFileHistory.ts
  21. +1
    -1
      src/commands/showLastQuickPick.ts
  22. +1
    -1
      src/commands/showQuickBranchHistory.ts
  23. +1
    -1
      src/commands/showQuickCommitDetails.ts
  24. +1
    -1
      src/commands/showQuickCommitFileDetails.ts
  25. +1
    -1
      src/commands/showQuickCurrentBranchHistory.ts
  26. +1
    -1
      src/commands/showQuickFileHistory.ts
  27. +1
    -1
      src/commands/showQuickRepoStatus.ts
  28. +1
    -1
      src/commands/toggleBlame.ts
  29. +1
    -1
      src/commands/toggleCodeLens.ts
  30. +10
    -0
      src/git/remotes/provider.ts
  31. +2
    -2
      src/quickPicks.ts
  32. +2
    -1
      src/quickPicks/branchHistory.ts
  33. +1
    -1
      src/quickPicks/branches.ts
  34. +36
    -2
      src/quickPicks/commitDetails.ts
  35. +2
    -1
      src/quickPicks/commitFileDetails.ts
  36. +15
    -0
      src/quickPicks/common.ts
  37. +2
    -1
      src/quickPicks/fileHistory.ts
  38. +0
    -52
      src/quickPicks/gitQuickPicks.ts
  39. +2
    -12
      src/quickPicks/remotes.ts
  40. +1
    -1
      src/quickPicks/repoStatus.ts

+ 2
- 18
src/commands.ts View File

@ -1,10 +1,8 @@
'use strict';
import { commands } from 'vscode';
import { BuiltInCommands } from './constants';
export * from './commands/common';
export * from './commands/keyboard';
export * from './commands/commands';
export * from './commands/closeUnchangedFiles';
export * from './commands/copyMessageToClipboard';
export * from './commands/copyShaToClipboard';
@ -30,18 +28,4 @@ export * from './commands/showQuickBranchHistory';
export * from './commands/showQuickCurrentBranchHistory';
export * from './commands/showQuickRepoStatus';
export * from './commands/toggleBlame';
export * from './commands/toggleCodeLens';
export type CommandContext = 'gitlens:canToggleCodeLens' | 'gitlens:enabled' | 'gitlens:isBlameable' | 'gitlens:key';
export const CommandContext = {
CanToggleCodeLens: 'gitlens:canToggleCodeLens' as CommandContext,
Enabled: 'gitlens:enabled' as CommandContext,
HasRemotes: 'gitlens:hasRemotes' as CommandContext,
IsBlameable: 'gitlens:isBlameable' as CommandContext,
Key: 'gitlens:key' as CommandContext
};
export function setCommandContext(key: CommandContext | string, value: any) {
return commands.executeCommand(BuiltInCommands.SetContext, key, value);
}
export * from './commands/toggleCodeLens';

+ 1
- 1
src/commands/closeUnchangedFiles.ts View File

@ -1,7 +1,7 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorTracker } from '../activeEditorTracker';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { TextEditorComparer, UriComparer } from '../comparers';
import { GitService } from '../gitService';
import { Logger } from '../logger';

src/commands/commands.ts → src/commands/common.ts View File

@ -41,6 +41,20 @@ export const Commands = {
ToggleCodeLens: 'gitlens.toggleCodeLens' as Commands
};
export type CommandContext = 'gitlens:canToggleCodeLens' | 'gitlens:enabled' | 'gitlens:isBlameable' | 'gitlens:key';
export const CommandContext = {
CanToggleCodeLens: 'gitlens:canToggleCodeLens' as CommandContext,
Enabled: 'gitlens:enabled' as CommandContext,
HasRemotes: 'gitlens:hasRemotes' as CommandContext,
IsBlameable: 'gitlens:isBlameable' as CommandContext,
Key: 'gitlens:key' as CommandContext
};
export function setCommandContext(key: CommandContext | string, value: any) {
return commands.executeCommand(BuiltInCommands.SetContext, key, value);
}
export abstract class Command extends Disposable {
private _disposable: Disposable;

+ 1
- 1
src/commands/copyMessageToClipboard.ts View File

@ -1,7 +1,7 @@
'use strict';
import { Iterables } from '../system';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { copy } from 'copy-paste';

+ 1
- 1
src/commands/copyShaToClipboard.ts View File

@ -1,7 +1,7 @@
'use strict';
import { Iterables } from '../system';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';
import { copy } from 'copy-paste';

+ 1
- 1
src/commands/diffDirectory.ts View File

@ -1,7 +1,7 @@
'use strict';
import { Iterables } from '../system';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { GitService } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, BranchesQuickPick } from '../quickPicks';

+ 1
- 1
src/commands/diffLineWithPrevious.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { BuiltInCommands } from '../constants';
import { GitCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/diffLineWithWorking.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { GitCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/diffWithBranch.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { BuiltInCommands } from '../constants';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/diffWithNext.ts View File

@ -1,7 +1,7 @@
'use strict';
import { Iterables } from '../system';
import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { BuiltInCommands } from '../constants';
import { GitLogCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/diffWithPrevious.ts View File

@ -1,7 +1,7 @@
'use strict';
import { Iterables } from '../system';
import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { BuiltInCommands } from '../constants';
import { GitCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/diffWithWorking.ts View File

@ -1,7 +1,7 @@
'use strict';
// import { Iterables } from '../system';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { BuiltInCommands } from '../constants';
import { GitCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 2
- 2
src/commands/keyboard.ts View File

@ -1,7 +1,7 @@
'use strict';
import { commands, Disposable, QuickPickItem } from 'vscode';
import { CommandContext, setCommandContext } from '../commands';
import { CommandQuickPickItem, OpenFileCommandQuickPickItem } from '../quickPicks/quickPicks';
import { CommandContext, setCommandContext } from './common';
import { CommandQuickPickItem, OpenFileCommandQuickPickItem } from '../quickPicks';
import { Logger } from '../logger';
const keyNoopCommand = Object.create(null) as QuickPickItem;

+ 1
- 1
src/commands/openChangedFiles.ts View File

@ -1,6 +1,6 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands, openEditor } from './commands';
import { ActiveEditorCommand, Commands, openEditor } from './common';
import { GitService } from '../gitService';
import { Logger } from '../logger';
import * as path from 'path';

+ 1
- 1
src/commands/openCommitInRemote.ts View File

@ -1,7 +1,7 @@
'use strict';
import { Arrays } from '../system';
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { GitCommit, GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/openFileInRemote.ts View File

@ -1,7 +1,7 @@
'use strict';
import { Arrays } from '../system';
import { commands, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/openInRemote.ts View File

@ -1,6 +1,6 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCommand, Commands } from './common';
import { GitRemote, RemoteOpenType } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickPicks';

+ 1
- 1
src/commands/showBlame.ts View File

@ -1,7 +1,7 @@
'use strict';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { BlameAnnotationController } from '../blameAnnotationController';
import { Commands, EditorCommand } from './commands';
import { Commands, EditorCommand } from './common';
import { Logger } from '../logger';
export class ShowBlameCommand extends EditorCommand {

+ 1
- 1
src/commands/showBlameHistory.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand } from './commands';
import { Commands, EditorCommand } from './common';
import { BuiltInCommands } from '../constants';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/showFileHistory.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { Commands, EditorCommand } from './commands';
import { Commands, EditorCommand } from './common';
import { BuiltInCommands } from '../constants';
import { GitService, GitUri } from '../gitService';
import { Logger } from '../logger';

+ 1
- 1
src/commands/showLastQuickPick.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, window } from 'vscode';
import { Command, Commands, getLastCommand } from './commands';
import { Command, Commands, getLastCommand } from './common';
import { Logger } from '../logger';
export class ShowLastQuickPickCommand extends Command {

+ 1
- 1
src/commands/showQuickBranchHistory.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands } from '../commands';
import { ActiveEditorCachedCommand, Commands } from './common';
import { GitService, GitUri, IGitLog } from '../gitService';
import { Logger } from '../logger';
import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickPicks';

+ 1
- 1
src/commands/showQuickCommitDetails.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands } from './commands';
import { ActiveEditorCachedCommand, Commands } from './common';
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';

+ 1
- 1
src/commands/showQuickCommitFileDetails.ts View File

@ -1,6 +1,6 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands } from './commands';
import { ActiveEditorCachedCommand, Commands } from './common';
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks';

+ 1
- 1
src/commands/showQuickCurrentBranchHistory.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands } from '../commands';
import { ActiveEditorCachedCommand, Commands } from './common';
import { GitService } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem } from '../quickPicks';

+ 1
- 1
src/commands/showQuickFileHistory.ts View File

@ -1,6 +1,6 @@
'use strict';
import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands } from '../commands';
import { ActiveEditorCachedCommand, Commands } from './common';
import { GitService, GitUri, IGitLog } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';

+ 1
- 1
src/commands/showQuickRepoStatus.ts View File

@ -1,6 +1,6 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCachedCommand, Commands } from './commands';
import { ActiveEditorCachedCommand, Commands } from './common';
import { GitService } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';

+ 1
- 1
src/commands/toggleBlame.ts View File

@ -1,7 +1,7 @@
'use strict';
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { BlameAnnotationController } from '../blameAnnotationController';
import { Commands, EditorCommand } from './commands';
import { Commands, EditorCommand } from './common';
import { Logger } from '../logger';
export class ToggleBlameCommand extends EditorCommand {

+ 1
- 1
src/commands/toggleCodeLens.ts View File

@ -1,6 +1,6 @@
'use strict';
import { TextEditor, TextEditorEdit } from 'vscode';
import { Commands, EditorCommand } from './commands';
import { Commands, EditorCommand } from './common';
import { GitService } from '../gitService';
export class ToggleCodeLensCommand extends EditorCommand {

+ 10
- 0
src/git/remotes/provider.ts View File

@ -4,6 +4,16 @@ import { BuiltInCommands } from '../../constants';
export type RemoteOpenType = 'branch' | 'commit' | 'file' | 'working-file';
export function getNameFromRemoteOpenType(type: RemoteOpenType) {
switch (type) {
case 'branch': return 'Branch';
case 'commit': return 'Commit';
case 'file': return 'File';
case 'working-file': return 'Working File';
default: return '';
}
}
export abstract class RemoteProvider {
constructor(public domain: string, public path: string) { }

+ 2
- 2
src/quickPicks.ts View File

@ -1,7 +1,7 @@
'use strict';
export * from './quickPicks/common';
export * from './quickPicks/branches';
export * from './quickPicks/quickPicks';
export * from './quickPicks/gitQuickPicks';
export * from './quickPicks/commitDetails';
export * from './quickPicks/commitFileDetails';
export * from './quickPicks/branchHistory';

+ 2
- 1
src/quickPicks/branchHistory.ts View File

@ -2,8 +2,9 @@
import { Arrays, Iterables } from '../system';
import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, KeyNoopCommand } from '../commands';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './common';
import { GitService, GitUri, IGitLog } from '../gitService';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, OpenRemotesCommandQuickPickItem, showQuickPickProgress } from '../quickPicks';
import { OpenRemotesCommandQuickPickItem } from './remotes';
export class BranchHistoryQuickPick {

+ 1
- 1
src/quickPicks/branches.ts View File

@ -1,7 +1,7 @@
'use strict';
import { QuickPickItem, QuickPickOptions, window } from 'vscode';
import { GitBranch } from '../gitService';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './common';
export class BranchQuickPickItem implements QuickPickItem {

+ 36
- 2
src/quickPicks/commitDetails.ts View File

@ -2,11 +2,45 @@
import { Arrays, Iterables } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, KeyNoopCommand } from '../commands';
import { GitLogCommit, GitService, IGitLog } from '../gitService';
import { CommandQuickPickItem, CommitWithFileStatusQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFilesCommandQuickPickItem, OpenRemotesCommandQuickPickItem } from '../quickPicks';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem } from './common';
import { getGitStatusIcon, Git, GitCommit, GitLogCommit, GitService, GitStatusFileStatus, GitUri, IGitLog, IGitStatusFile } from '../gitService';
import { OpenRemotesCommandQuickPickItem } from './remotes';
import * as moment from 'moment';
import * as path from 'path';
export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickItem {
fileName: string;
gitUri: GitUri;
sha: string;
shortSha: string;
status: GitStatusFileStatus;
constructor(commit: GitCommit, status: IGitStatusFile) {
const icon = getGitStatusIcon(status.status);
let directory = Git.normalizePath(path.dirname(status.fileName));
if (!directory || directory === '.') {
directory = undefined;
}
let description = (status.status === 'R' && status.originalFileName)
? `${directory || ''} \u00a0\u2190\u00a0 ${status.originalFileName}`
: directory;
super(GitService.toGitContentUri(commit.sha, status.fileName, commit.repoPath, commit.originalFileName), {
label: `\u00a0\u00a0\u00a0\u00a0${icon}\u00a0\u00a0 ${path.basename(status.fileName)}`,
description: description
});
this.fileName = status.fileName;
this.gitUri = new GitUri(Uri.file(path.resolve(commit.repoPath, status.fileName)));
this.sha = commit.sha;
this.shortSha = commit.shortSha;
this.status = status.status;
}
}
export class OpenCommitFilesCommandQuickPickItem extends OpenFilesCommandQuickPickItem {
constructor(commit: GitLogCommit, item?: QuickPickItem) {

+ 2
- 1
src/quickPicks/commitFileDetails.ts View File

@ -2,8 +2,9 @@
import { Arrays, Iterables } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, KeyNoopCommand } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem } from './common';
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenRemotesCommandQuickPickItem } from '../quickPicks';
import { OpenRemotesCommandQuickPickItem } from './remotes';
import * as moment from 'moment';
import * as path from 'path';

src/quickPicks/quickPicks.ts → src/quickPicks/common.ts View File

@ -2,7 +2,9 @@
import { CancellationTokenSource, commands, Disposable, QuickPickItem, QuickPickOptions, TextEditor, Uri, window, workspace } from 'vscode';
import { Commands, Keyboard, KeyboardScope, KeyMapping, openEditor } from '../commands';
import { IAdvancedConfig } from '../configuration';
import { GitCommit } from '../gitService';
// import { Logger } from '../logger';
import * as moment from 'moment';
export function getQuickPickIgnoreFocusOut() {
return !workspace.getConfiguration('gitlens').get<IAdvancedConfig>('advanced').quickPick.closeOnFocusOut;
@ -106,4 +108,17 @@ export class OpenFilesCommandQuickPickItem extends CommandQuickPickItem {
}
return undefined;
}
}
export class CommitQuickPickItem implements QuickPickItem {
label: string;
description: string;
detail: string;
constructor(public commit: GitCommit, descriptionSuffix: string = '') {
this.label = `${commit.author}, ${moment(commit.date).fromNow()}`;
this.description = `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha}${descriptionSuffix}`;
this.detail = commit.message;
}
}

+ 2
- 1
src/quickPicks/fileHistory.ts View File

@ -2,8 +2,9 @@
import { Arrays, Iterables } from '../system';
import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard, KeyNoopCommand } from '../commands';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './common';
import { GitService, GitUri, IGitLog } from '../gitService';
import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, OpenRemotesCommandQuickPickItem, showQuickPickProgress } from '../quickPicks';
import { OpenRemotesCommandQuickPickItem } from './remotes';
import * as path from 'path';
export class FileHistoryQuickPick {

+ 0
- 52
src/quickPicks/gitQuickPicks.ts View File

@ -1,52 +0,0 @@
'use strict';
import { QuickPickItem, Uri } from 'vscode';
import { getGitStatusIcon, Git, GitCommit, GitStatusFileStatus, GitService, GitUri, IGitStatusFile } from '../gitService';
import { OpenFileCommandQuickPickItem } from './quickPicks';
import * as moment from 'moment';
import * as path from 'path';
export class CommitQuickPickItem implements QuickPickItem {
label: string;
description: string;
detail: string;
constructor(public commit: GitCommit, descriptionSuffix: string = '') {
this.label = `${commit.author}, ${moment(commit.date).fromNow()}`;
this.description = `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.shortSha}${descriptionSuffix}`;
this.detail = commit.message;
}
}
export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickItem {
fileName: string;
gitUri: GitUri;
sha: string;
shortSha: string;
status: GitStatusFileStatus;
constructor(commit: GitCommit, status: IGitStatusFile) {
const icon = getGitStatusIcon(status.status);
let directory = Git.normalizePath(path.dirname(status.fileName));
if (!directory || directory === '.') {
directory = undefined;
}
let description = (status.status === 'R' && status.originalFileName)
? `${directory || ''} \u00a0\u2190\u00a0 ${status.originalFileName}`
: directory;
super(GitService.toGitContentUri(commit.sha, status.fileName, commit.repoPath, commit.originalFileName), {
label: `\u00a0\u00a0\u00a0\u00a0${icon}\u00a0\u00a0 ${path.basename(status.fileName)}`,
description: description
});
this.fileName = status.fileName;
this.gitUri = new GitUri(Uri.file(path.resolve(commit.repoPath, status.fileName)));
this.sha = commit.sha;
this.shortSha = commit.shortSha;
this.status = status.status;
}
}

+ 2
- 12
src/quickPicks/remotes.ts View File

@ -1,20 +1,10 @@
'use strict';
import { QuickPickOptions, window } from 'vscode';
import { Commands } from '../commands';
import { GitRemote, RemoteOpenType } from '../gitService';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './common';
import { getNameFromRemoteOpenType, GitRemote, RemoteOpenType } from '../gitService';
import * as path from 'path';
function getNameFromRemoteOpenType(type: RemoteOpenType) {
switch (type) {
case 'branch': return 'Branch';
case 'commit': return 'Commit';
case 'file': return 'File';
case 'working-file': return 'Working File';
default: return '';
}
}
export class OpenRemoteCommandQuickPickItem extends CommandQuickPickItem {
private remote: GitRemote;

+ 1
- 1
src/quickPicks/repoStatus.ts View File

@ -2,8 +2,8 @@
import { Iterables } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from './common';
import { Git, GitStatusFile, GitUri, IGitStatus } from '../gitService';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from '../quickPicks';
import * as path from 'path';
export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {

Loading…
Cancel
Save