diff --git a/src/commands/diffBranchWithBranch.ts b/src/commands/diffBranchWithBranch.ts index 7cf84c0..a5c6d8b 100644 --- a/src/commands/diffBranchWithBranch.ts +++ b/src/commands/diffBranchWithBranch.ts @@ -5,7 +5,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; import { Messages } from '../messages'; -import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickPicks'; +import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickPicks/quickPicks'; export interface DiffBranchWithBranchCommandArgs { ref1?: string; diff --git a/src/commands/diffDirectory.ts b/src/commands/diffDirectory.ts index 3fcf44c..d69ce0a 100644 --- a/src/commands/diffDirectory.ts +++ b/src/commands/diffDirectory.ts @@ -7,7 +7,7 @@ import { Container } from '../container'; import { ComparisonResultsNode } from '../views/explorerNodes'; import { Logger } from '../logger'; import { Messages } from '../messages'; -import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickPicks'; +import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickPicks/quickPicks'; export interface DiffDirectoryCommandArgs { ref1?: string; diff --git a/src/commands/diffWithBranch.ts b/src/commands/diffWithBranch.ts index f05f37f..0479c4b 100644 --- a/src/commands/diffWithBranch.ts +++ b/src/commands/diffWithBranch.ts @@ -7,7 +7,7 @@ import { Container } from '../container'; import { DiffWithCommandArgs } from './diffWith'; import { GitUri } from '../gitService'; import { Messages } from '../messages'; -import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickPicks'; +import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickPicks/quickPicks'; import * as path from 'path'; export interface DiffWithBranchCommandArgs { diff --git a/src/commands/diffWithRevision.ts b/src/commands/diffWithRevision.ts index ba19ef0..dbded8a 100644 --- a/src/commands/diffWithRevision.ts +++ b/src/commands/diffWithRevision.ts @@ -8,7 +8,7 @@ import { DiffWithCommandArgs } from './diffWith'; import { GitUri } from '../gitService'; import { Logger } from '../logger'; import { Messages } from '../messages'; -import { CommandQuickPickItem, FileHistoryQuickPick, ShowBranchesAndTagsQuickPickItem } from '../quickPicks'; +import { CommandQuickPickItem, FileHistoryQuickPick, ShowBranchesAndTagsQuickPickItem } from '../quickPicks/quickPicks'; export interface DiffWithRevisionCommandArgs { maxCount?: number; diff --git a/src/commands/openBranchInRemote.ts b/src/commands/openBranchInRemote.ts index c1d696d..5c50e45 100644 --- a/src/commands/openBranchInRemote.ts +++ b/src/commands/openBranchInRemote.ts @@ -5,7 +5,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitUri } from '../gitService'; import { Logger } from '../logger'; -import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks'; +import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks/quickPicks'; import { OpenInRemoteCommandArgs } from './openInRemote'; export interface OpenBranchInRemoteCommandArgs { diff --git a/src/commands/openFileRevision.ts b/src/commands/openFileRevision.ts index 55eb0ff..15f6019 100644 --- a/src/commands/openFileRevision.ts +++ b/src/commands/openFileRevision.ts @@ -8,7 +8,7 @@ import { Container } from '../container'; import { GitUri } from '../gitService'; import { Logger } from '../logger'; import { Messages } from '../messages'; -import { CommandQuickPickItem, FileHistoryQuickPick, ShowBranchesAndTagsQuickPickItem } from '../quickPicks'; +import { CommandQuickPickItem, FileHistoryQuickPick, ShowBranchesAndTagsQuickPickItem } from '../quickPicks/quickPicks'; export interface OpenFileRevisionCommandArgs { uri?: Uri; diff --git a/src/commands/openInRemote.ts b/src/commands/openInRemote.ts index 0f89e0f..604071a 100644 --- a/src/commands/openInRemote.ts +++ b/src/commands/openInRemote.ts @@ -5,7 +5,7 @@ import { ActiveEditorCommand, Commands } from './common'; import { GlyphChars } from '../constants'; import { GitLogCommit, GitRemote, GitService, RemoteResource, RemoteResourceType } from '../gitService'; import { Logger } from '../logger'; -import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickPicks'; +import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickPicks/quickPicks'; export interface OpenInRemoteCommandArgs { remote?: string; diff --git a/src/commands/showCommitSearch.ts b/src/commands/showCommitSearch.ts index 8d515e1..f57075f 100644 --- a/src/commands/showCommitSearch.ts +++ b/src/commands/showCommitSearch.ts @@ -6,7 +6,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitRepoSearchBy, GitService, GitUri } from '../gitService'; import { Logger } from '../logger'; -import { CommandQuickPickItem, CommitsQuickPick, RepositoriesQuickPick, ShowCommitsSearchInResultsQuickPickItem } from '../quickPicks'; +import { CommandQuickPickItem, CommitsQuickPick, RepositoriesQuickPick, ShowCommitsSearchInResultsQuickPickItem } from '../quickPicks/quickPicks'; import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails'; const searchByRegex = /^([@~=:#])/; diff --git a/src/commands/showQuickBranchHistory.ts b/src/commands/showQuickBranchHistory.ts index 659e565..3e3c581 100644 --- a/src/commands/showQuickBranchHistory.ts +++ b/src/commands/showQuickBranchHistory.ts @@ -7,7 +7,7 @@ import { Container } from '../container'; import { GitLog, GitUri } from '../gitService'; import { Logger } from '../logger'; import { Messages } from '../messages'; -import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickPicks'; +import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickPicks/quickPicks'; import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails'; export interface ShowQuickBranchHistoryCommandArgs { diff --git a/src/commands/showQuickCommitDetails.ts b/src/commands/showQuickCommitDetails.ts index 080e372..a306fd0 100644 --- a/src/commands/showQuickCommitDetails.ts +++ b/src/commands/showQuickCommitDetails.ts @@ -5,7 +5,7 @@ import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri, isC import { GlyphChars } from '../constants'; import { GitCommit, GitLog, GitLogCommit, GitUri } from '../gitService'; import { Logger } from '../logger'; -import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks'; +import { CommandQuickPickItem, CommitQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks/quickPicks'; import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails'; import { Messages } from '../messages'; import * as path from 'path'; @@ -124,7 +124,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand { args ]); - const pick = await CommitDetailsQuickPick.show(args.commit as GitLogCommit, uri, args.goBackCommand, currentCommand, args.repoLog); + const pick = await CommitQuickPick.show(args.commit as GitLogCommit, uri, args.goBackCommand, currentCommand, args.repoLog); if (pick === undefined) return undefined; if (!(pick instanceof CommitWithFileStatusQuickPickItem)) return pick.execute(); diff --git a/src/commands/showQuickCommitFileDetails.ts b/src/commands/showQuickCommitFileDetails.ts index 3df0385..f78fe47 100644 --- a/src/commands/showQuickCommitFileDetails.ts +++ b/src/commands/showQuickCommitFileDetails.ts @@ -5,7 +5,7 @@ import { ActiveEditorCachedCommand, CommandContext, Commands, getCommandUri, isC import { GlyphChars } from '../constants'; import { GitCommit, GitLog, GitLogCommit, GitService, GitUri } from '../gitService'; import { Logger } from '../logger'; -import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks'; +import { CommandQuickPickItem, CommitFileQuickPick } from '../quickPicks/quickPicks'; import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails'; import { Messages } from '../messages'; import * as path from 'path'; @@ -130,7 +130,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand args ]); - const pick = await CommitFileDetailsQuickPick.show(args.commit as GitLogCommit, uri, args.goBackCommand, currentCommand, args.fileLog); + const pick = await CommitFileQuickPick.show(args.commit as GitLogCommit, uri, args.goBackCommand, currentCommand, args.fileLog); if (pick === undefined) return undefined; if (pick instanceof CommandQuickPickItem) return pick.execute(); diff --git a/src/commands/showQuickCurrentBranchHistory.ts b/src/commands/showQuickCurrentBranchHistory.ts index bba7de2..9a6852f 100644 --- a/src/commands/showQuickCurrentBranchHistory.ts +++ b/src/commands/showQuickCurrentBranchHistory.ts @@ -4,7 +4,7 @@ import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common'; import { Container } from '../container'; import { Logger } from '../logger'; import { Messages } from '../messages'; -import { CommandQuickPickItem } from '../quickPicks'; +import { CommandQuickPickItem } from '../quickPicks/quickPicks'; import { ShowQuickBranchHistoryCommandArgs } from './showQuickBranchHistory'; export interface ShowQuickCurrentBranchHistoryCommandArgs { diff --git a/src/commands/showQuickFileHistory.ts b/src/commands/showQuickFileHistory.ts index b005fcc..b79b73a 100644 --- a/src/commands/showQuickFileHistory.ts +++ b/src/commands/showQuickFileHistory.ts @@ -6,7 +6,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitLog, GitUri } from '../gitService'; import { Logger } from '../logger'; -import { CommandQuickPickItem, FileHistoryQuickPick, ShowCommitsInResultsQuickPickItem } from '../quickPicks'; +import { CommandQuickPickItem, FileHistoryQuickPick, ShowCommitsInResultsQuickPickItem } from '../quickPicks/quickPicks'; import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails'; import { Messages } from '../messages'; import * as path from 'path'; diff --git a/src/commands/showQuickRepoStatus.ts b/src/commands/showQuickRepoStatus.ts index f668f6a..2da1831 100644 --- a/src/commands/showQuickRepoStatus.ts +++ b/src/commands/showQuickRepoStatus.ts @@ -4,7 +4,7 @@ import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common'; import { Container } from '../container'; import { Logger } from '../logger'; import { Messages } from '../messages'; -import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks'; +import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks/quickPicks'; export interface ShowQuickRepoStatusCommandArgs { goBackCommand?: CommandQuickPickItem; diff --git a/src/commands/showQuickStashList.ts b/src/commands/showQuickStashList.ts index 12b7107..23acfeb 100644 --- a/src/commands/showQuickStashList.ts +++ b/src/commands/showQuickStashList.ts @@ -6,7 +6,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; import { Messages } from '../messages'; -import { CommandQuickPickItem, StashListQuickPick } from '../quickPicks'; +import { CommandQuickPickItem, StashListQuickPick } from '../quickPicks/quickPicks'; import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails'; export interface ShowQuickStashListCommandArgs { diff --git a/src/commands/stashApply.ts b/src/commands/stashApply.ts index 6ad866c..5fcc335 100644 --- a/src/commands/stashApply.ts +++ b/src/commands/stashApply.ts @@ -6,7 +6,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitStashCommit } from '../gitService'; import { Logger } from '../logger'; -import { CommandQuickPickItem, RepositoriesQuickPick, StashListQuickPick } from '../quickPicks'; +import { CommandQuickPickItem, RepositoriesQuickPick, StashListQuickPick } from '../quickPicks/quickPicks'; export interface StashApplyCommandArgs { confirm?: boolean; diff --git a/src/commands/stashDelete.ts b/src/commands/stashDelete.ts index be71779..8a7492a 100644 --- a/src/commands/stashDelete.ts +++ b/src/commands/stashDelete.ts @@ -5,7 +5,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitStashCommit } from '../gitService'; import { Logger } from '../logger'; -import { CommandQuickPickItem } from '../quickPicks'; +import { CommandQuickPickItem } from '../quickPicks/quickPicks'; export interface StashDeleteCommandArgs { confirm?: boolean; diff --git a/src/commands/stashSave.ts b/src/commands/stashSave.ts index 182a729..b0d4f65 100644 --- a/src/commands/stashSave.ts +++ b/src/commands/stashSave.ts @@ -5,7 +5,7 @@ import { Command, Commands } from './common'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; -import { CommandQuickPickItem, RepositoriesQuickPick } from '../quickPicks'; +import { CommandQuickPickItem, RepositoriesQuickPick } from '../quickPicks/quickPicks'; export interface StashSaveCommandArgs { message?: string; diff --git a/src/git/formatters/commit.ts b/src/git/formatters/commitFormatter.ts similarity index 100% rename from src/git/formatters/commit.ts rename to src/git/formatters/commitFormatter.ts diff --git a/src/git/formatters/formatters.ts b/src/git/formatters/formatters.ts new file mode 100644 index 0000000..ff1a2c6 --- /dev/null +++ b/src/git/formatters/formatters.ts @@ -0,0 +1,4 @@ +'use strict'; + +export * from './commitFormatter'; +export * from './statusFormatter'; diff --git a/src/git/formatters/status.ts b/src/git/formatters/statusFormatter.ts similarity index 100% rename from src/git/formatters/status.ts rename to src/git/formatters/statusFormatter.ts diff --git a/src/git/git.ts b/src/git/git.ts index c1cf415..80f9710 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -9,14 +9,7 @@ import * as path from 'path'; export { IGit }; export * from './models/models'; -export * from './parsers/blameParser'; -export * from './parsers/branchParser'; -export * from './parsers/diffParser'; -export * from './parsers/logParser'; -export * from './parsers/remoteParser'; -export * from './parsers/stashParser'; -export * from './parsers/statusParser'; -export * from './parsers/tagParser'; +export * from './parsers/parsers'; export * from './remotes/provider'; let git: IGit; diff --git a/src/git/models/models.ts b/src/git/models/models.ts index 5de9860..2c03bc9 100644 --- a/src/git/models/models.ts +++ b/src/git/models/models.ts @@ -1,4 +1,5 @@ 'use strict'; + export * from './blame'; export * from './blameCommit'; export * from './branch'; @@ -11,4 +12,4 @@ export * from './repository'; export * from './stash'; export * from './stashCommit'; export * from './status'; -export * from './tag'; \ No newline at end of file +export * from './tag'; diff --git a/src/git/parsers/parsers.ts b/src/git/parsers/parsers.ts new file mode 100644 index 0000000..1366911 --- /dev/null +++ b/src/git/parsers/parsers.ts @@ -0,0 +1,10 @@ +'use strict'; + +export * from './blameParser'; +export * from './branchParser'; +export * from './diffParser'; +export * from './logParser'; +export * from './remoteParser'; +export * from './stashParser'; +export * from './statusParser'; +export * from './tagParser'; diff --git a/src/gitService.ts b/src/gitService.ts index 1a92979..1d9b07b 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -14,8 +14,7 @@ import * as path from 'path'; export { GitUri, IGit, IGitCommitInfo }; export * from './git/models/models'; -export * from './git/formatters/commit'; -export * from './git/formatters/status'; +export * from './git/formatters/formatters'; export { getNameFromRemoteResource, RemoteProvider, RemoteResource, RemoteResourceType } from './git/remotes/provider'; export { RemoteProviderFactory } from './git/remotes/factory'; diff --git a/src/quickPicks.ts b/src/quickPicks.ts deleted file mode 100644 index 42b6c77..0000000 --- a/src/quickPicks.ts +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; -export * from './quickPicks/common'; - -export * from './quickPicks/branches'; -export * from './quickPicks/branchesAndTags'; -export * from './quickPicks/commitDetails'; -export * from './quickPicks/commitFileDetails'; -export * from './quickPicks/commits'; -export * from './quickPicks/branchHistory'; -export * from './quickPicks/fileHistory'; -export * from './quickPicks/remotes'; -export * from './quickPicks/repositories'; -export * from './quickPicks/repoStatus'; -export * from './quickPicks/stashList'; \ No newline at end of file diff --git a/src/quickPicks/branchHistory.ts b/src/quickPicks/branchHistoryQuickPick.ts similarity index 97% rename from src/quickPicks/branchHistory.ts rename to src/quickPicks/branchHistoryQuickPick.ts index 816b85e..6df569c 100644 --- a/src/quickPicks/branchHistory.ts +++ b/src/quickPicks/branchHistoryQuickPick.ts @@ -2,12 +2,12 @@ import { Iterables, Strings } from '../system'; import { CancellationTokenSource, QuickPickOptions, window } from 'vscode'; import { Commands, ShowCommitSearchCommandArgs, ShowQuickBranchHistoryCommandArgs } from '../commands'; -import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './common'; +import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './commonQuickPicks'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitLog, GitUri, RemoteResource } from '../gitService'; import { KeyNoopCommand } from '../keyboard'; -import { OpenRemotesCommandQuickPickItem } from './remotes'; +import { OpenRemotesCommandQuickPickItem } from './remotesQuickPick'; export class BranchHistoryQuickPick { diff --git a/src/quickPicks/branchesAndTags.ts b/src/quickPicks/branchesAndTagsQuickPick.ts similarity index 98% rename from src/quickPicks/branchesAndTags.ts rename to src/quickPicks/branchesAndTagsQuickPick.ts index e4a695f..e14c2e2 100644 --- a/src/quickPicks/branchesAndTags.ts +++ b/src/quickPicks/branchesAndTagsQuickPick.ts @@ -1,6 +1,6 @@ 'use strict'; import { CancellationTokenSource, QuickPickItem, QuickPickOptions, window } from 'vscode'; -import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './common'; +import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from './commonQuickPicks'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitBranch, GitTag } from '../gitService'; diff --git a/src/quickPicks/branches.ts b/src/quickPicks/branchesQuickPick.ts similarity index 98% rename from src/quickPicks/branches.ts rename to src/quickPicks/branchesQuickPick.ts index 5a05122..c04453c 100644 --- a/src/quickPicks/branches.ts +++ b/src/quickPicks/branchesQuickPick.ts @@ -1,6 +1,6 @@ 'use strict'; import { QuickPickItem, QuickPickOptions, window } from 'vscode'; -import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './common'; +import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './commonQuickPicks'; import { GlyphChars } from '../constants'; import { GitBranch } from '../gitService'; diff --git a/src/quickPicks/commitFileDetails.ts b/src/quickPicks/commitFileQuickPick.ts similarity index 99% rename from src/quickPicks/commitFileDetails.ts rename to src/quickPicks/commitFileQuickPick.ts index e7557dc..bbf1729 100644 --- a/src/quickPicks/commitFileDetails.ts +++ b/src/quickPicks/commitFileQuickPick.ts @@ -2,12 +2,12 @@ import { Iterables, Strings } from '../system'; import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode'; import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, openEditor, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands'; -import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem } from './common'; +import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem } from './commonQuickPicks'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitLog, GitLogCommit, GitUri, RemoteResource } from '../gitService'; import { KeyCommand, KeyNoopCommand } from '../keyboard'; -import { OpenRemotesCommandQuickPickItem } from './remotes'; +import { OpenRemotesCommandQuickPickItem } from './remotesQuickPick'; import * as path from 'path'; export class ApplyCommitFileChangesCommandQuickPickItem extends CommandQuickPickItem { @@ -65,7 +65,7 @@ export class OpenCommitFileRevisionCommandQuickPickItem extends OpenFileCommandQ } } -export class CommitFileDetailsQuickPick { +export class CommitFileQuickPick { static async show(commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, fileLog?: GitLog): Promise { const items: CommandQuickPickItem[] = []; diff --git a/src/quickPicks/commitDetails.ts b/src/quickPicks/commitQuickPick.ts similarity index 99% rename from src/quickPicks/commitDetails.ts rename to src/quickPicks/commitQuickPick.ts index bb7f44f..01cd8ab 100644 --- a/src/quickPicks/commitDetails.ts +++ b/src/quickPicks/commitQuickPick.ts @@ -2,12 +2,12 @@ import { Arrays, Iterables, Strings } from '../system'; import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode'; import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffDirectoryCommandArgs, DiffWithPreviousCommandArgs, ShowQuickCommitDetailsCommandArgs, StashApplyCommandArgs, StashDeleteCommandArgs } from '../commands'; -import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem, QuickPickItem, ShowCommitInResultsQuickPickItem } from './common'; +import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem, QuickPickItem, ShowCommitInResultsQuickPickItem } from './commonQuickPicks'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { getGitStatusOcticon, GitLog, GitLogCommit, GitStashCommit, GitStatusFile, GitStatusFileStatus, GitUri, IGitStatusFile, RemoteResource } from '../gitService'; import { KeyCommand, KeyNoopCommand, Keys } from '../keyboard'; -import { OpenRemotesCommandQuickPickItem } from './remotes'; +import { OpenRemotesCommandQuickPickItem } from './remotesQuickPick'; import * as path from 'path'; export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickItem { @@ -87,7 +87,7 @@ export class OpenCommitFileRevisionsCommandQuickPickItem extends OpenFilesComman } } -export class CommitDetailsQuickPick { +export class CommitQuickPick { static async show(commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, repoLog?: GitLog): Promise { await commit.resolvePreviousFileSha(); diff --git a/src/quickPicks/commits.ts b/src/quickPicks/commitsQuickPick.ts similarity index 98% rename from src/quickPicks/commits.ts rename to src/quickPicks/commitsQuickPick.ts index c37a0e3..d2d3b0c 100644 --- a/src/quickPicks/commits.ts +++ b/src/quickPicks/commitsQuickPick.ts @@ -4,7 +4,7 @@ import { CancellationTokenSource, QuickPickOptions, window } from 'vscode'; import { Container } from '../container'; import { GitLog } from '../gitService'; import { KeyNoopCommand } from '../keyboard'; -import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, MessageQuickPickItem, showQuickPickProgress } from '../quickPicks'; +import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, MessageQuickPickItem, showQuickPickProgress } from '../quickPicks/quickPicks'; export class CommitsQuickPick { diff --git a/src/quickPicks/common.ts b/src/quickPicks/commonQuickPicks.ts similarity index 99% rename from src/quickPicks/common.ts rename to src/quickPicks/commonQuickPicks.ts index 74d304d..3344946 100644 --- a/src/quickPicks/common.ts +++ b/src/quickPicks/commonQuickPicks.ts @@ -1,7 +1,7 @@ 'use strict'; import { Strings } from '../system'; import { CancellationTokenSource, commands, QuickPickItem, QuickPickOptions, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode'; -import { BranchesAndTagsQuickPick, BranchOrTagQuickPickItem } from './branchesAndTags'; +import { BranchesAndTagsQuickPick, BranchOrTagQuickPickItem } from './branchesAndTagsQuickPick'; import { Commands, openEditor } from '../commands'; import { configuration } from '../configuration'; import { GlyphChars } from '../constants'; diff --git a/src/quickPicks/fileHistory.ts b/src/quickPicks/fileHistoryQuickPick.ts similarity index 98% rename from src/quickPicks/fileHistory.ts rename to src/quickPicks/fileHistoryQuickPick.ts index 98104aa..4450b48 100644 --- a/src/quickPicks/fileHistory.ts +++ b/src/quickPicks/fileHistoryQuickPick.ts @@ -2,12 +2,12 @@ import { Iterables, Strings } from '../system'; import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode'; import { Commands, ShowQuickCurrentBranchHistoryCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands'; -import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, ShowBranchesAndTagsQuickPickItem, showQuickPickProgress } from './common'; +import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, ShowBranchesAndTagsQuickPickItem, showQuickPickProgress } from './commonQuickPicks'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitLog, GitUri, RemoteResource } from '../gitService'; import { KeyNoopCommand } from '../keyboard'; -import { OpenRemotesCommandQuickPickItem } from './remotes'; +import { OpenRemotesCommandQuickPickItem } from './remotesQuickPick'; import * as path from 'path'; export class FileHistoryQuickPick { diff --git a/src/quickPicks/quickPicks.ts b/src/quickPicks/quickPicks.ts new file mode 100644 index 0000000..db0e185 --- /dev/null +++ b/src/quickPicks/quickPicks.ts @@ -0,0 +1,14 @@ +'use strict'; + +export * from './branchesAndTagsQuickPick'; +export * from './branchesQuickPick'; +export * from './branchHistoryQuickPick'; +export * from './commitFileQuickPick'; +export * from './commitQuickPick'; +export * from './commitsQuickPick'; +export * from './commonQuickPicks'; +export * from './fileHistoryQuickPick'; +export * from './remotesQuickPick'; +export * from './repositoriesQuickPick'; +export * from './repoStatusQuickPick'; +export * from './stashListQuickPick'; diff --git a/src/quickPicks/remotes.ts b/src/quickPicks/remotesQuickPick.ts similarity index 99% rename from src/quickPicks/remotes.ts rename to src/quickPicks/remotesQuickPick.ts index 5e7b229..752108a 100644 --- a/src/quickPicks/remotes.ts +++ b/src/quickPicks/remotesQuickPick.ts @@ -2,7 +2,7 @@ import { Strings } from '../system'; import { QuickPickOptions, window } from 'vscode'; import { Commands, OpenInRemoteCommandArgs } from '../commands'; -import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './common'; +import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './commonQuickPicks'; import { GlyphChars } from '../constants'; import { getNameFromRemoteResource, GitLogCommit, GitRemote, GitService, RemoteResource, RemoteResourceType } from '../gitService'; import * as path from 'path'; diff --git a/src/quickPicks/repoStatus.ts b/src/quickPicks/repoStatusQuickPick.ts similarity index 97% rename from src/quickPicks/repoStatus.ts rename to src/quickPicks/repoStatusQuickPick.ts index 112d168..06d4336 100644 --- a/src/quickPicks/repoStatus.ts +++ b/src/quickPicks/repoStatusQuickPick.ts @@ -1,327 +1,327 @@ -'use strict'; -import { Iterables, Strings } from '../system'; -import { commands, QuickPickOptions, TextDocumentShowOptions, window } from 'vscode'; -import { Commands, DiffWithPreviousCommandArgs, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands'; -import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, QuickPickItem } from './common'; -import { GlyphChars } from '../constants'; -import { Container } from '../container'; -import { GitCommitType, GitLogCommit, GitService, GitStatus, GitStatusFile, GitStatusFileStatus, GitUri } from '../gitService'; -import { Keys } from '../keyboard'; -import * as path from 'path'; - -export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem { - - public readonly status: GitStatusFile; - private readonly commit: GitLogCommit; - - constructor( - status: GitStatusFile, - realIndexStatus?: GitStatusFileStatus, - item?: QuickPickItem - ) { - const octicon = status.getOcticon(); - const description = status.getFormattedDirectory(true); - - super(status.uri, item || { - label: `${status.staged ? '$(check)' : GlyphChars.Space.repeat(3)}${Strings.pad(octicon, 2, 2)} ${path.basename(status.fileName)}`, - description: description - }); - - this.status = status; - if (status.indexStatus !== undefined) { - this.commit = new GitLogCommit(GitCommitType.File, status.repoPath, GitService.stagedUncommittedSha, 'You', undefined, new Date(), '', status.fileName, [status], status.status, status.originalFileName, 'HEAD', status.fileName); - } - else { - this.commit = new GitLogCommit(GitCommitType.File, status.repoPath, GitService.uncommittedSha, 'You', undefined, new Date(), '', status.fileName, [status], status.status, status.originalFileName, realIndexStatus !== undefined ? GitService.stagedUncommittedSha : 'HEAD', status.fileName); - } - } - - onDidPressKey(key: Keys): Promise<{} | undefined> { - return commands.executeCommand(Commands.DiffWithPrevious, - GitUri.fromFileStatus(this.status, this.status.repoPath), - { - commit: this.commit, - line: 0, - showOptions: { - preserveFocus: true, - preview: false - } as TextDocumentShowOptions - } as DiffWithPreviousCommandArgs) as Promise<{} | undefined>; - } -} - -export class OpenStatusFilesCommandQuickPickItem extends CommandQuickPickItem { - - constructor( - statuses: GitStatusFile[], - item?: QuickPickItem - ) { - const uris = statuses.map(f => f.uri); - - super(item || { - label: `$(file-symlink-file) Open Changed Files`, - description: '' - // detail: `Opens all of the changed files in the repository` - }, Commands.OpenChangedFiles, [ - undefined, - { - uris - } as OpenChangedFilesCommandArgs - ] - ); - } -} - -interface ComputedStatus { - staged: number; - stagedAddsAndChanges: GitStatusFile[]; - stagedStatus: string; - - unstaged: number; - unstagedAddsAndChanges: GitStatusFile[]; - unstagedStatus: string; -} - -export class RepoStatusQuickPick { - - private static computeStatus(files: GitStatusFile[]): ComputedStatus { - let stagedAdds = 0; - let unstagedAdds = 0; - let stagedChanges = 0; - let unstagedChanges = 0; - let stagedDeletes = 0; - let unstagedDeletes = 0; - - const stagedAddsAndChanges: GitStatusFile[] = []; - const unstagedAddsAndChanges: GitStatusFile[] = []; - - for (const f of files) { - switch (f.indexStatus) { - case 'A': - case '?': - stagedAdds++; - stagedAddsAndChanges.push(f); - break; - - case 'D': - stagedDeletes++; - break; - - case undefined: - break; - - default: - stagedChanges++; - stagedAddsAndChanges.push(f); - break; - } - - switch (f.workTreeStatus) { - case 'A': - case '?': - unstagedAdds++; - unstagedAddsAndChanges.push(f); - break; - - case 'D': - unstagedDeletes++; - break; - - case undefined: - break; - - default: - unstagedChanges++; - unstagedAddsAndChanges.push(f); - break; - } - } - - const staged = stagedAdds + stagedChanges + stagedDeletes; - const unstaged = unstagedAdds + unstagedChanges + unstagedDeletes; - - return { - staged: staged, - stagedStatus: staged > 0 ? `+${stagedAdds} ~${stagedChanges} -${stagedDeletes}` : '', - stagedAddsAndChanges: stagedAddsAndChanges, - unstaged: unstaged, - unstagedStatus: unstaged > 0 ? `+${unstagedAdds} ~${unstagedChanges} -${unstagedDeletes}` : '', - unstagedAddsAndChanges: unstagedAddsAndChanges - }; - } - - static async show(status: GitStatus, goBackCommand?: CommandQuickPickItem): Promise { - const items = [ - ...Iterables.flatMap(status.files, s => { - if (s.workTreeStatus !== undefined && s.indexStatus !== undefined) { - return [ - new OpenStatusFileCommandQuickPickItem(s.with({ indexStatus: null }), s.indexStatus), - new OpenStatusFileCommandQuickPickItem(s.with({ workTreeStatus: null })) - ]; - } - else { - return [new OpenStatusFileCommandQuickPickItem(s)]; - } - }) - ] as (OpenStatusFileCommandQuickPickItem | OpenStatusFilesCommandQuickPickItem | CommandQuickPickItem)[]; - - // Sort the status by staged and then filename - items.sort((a, b) => ((a as OpenStatusFileCommandQuickPickItem).status.staged ? -1 : 1) - ((b as OpenStatusFileCommandQuickPickItem).status.staged ? -1 : 1) || - (a as OpenStatusFileCommandQuickPickItem).status.fileName.localeCompare((b as OpenStatusFileCommandQuickPickItem).status.fileName)); - - const currentCommand = new CommandQuickPickItem({ - label: `go back ${GlyphChars.ArrowBack}`, - description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to ${GlyphChars.Space}$(git-branch) ${status.branch} status` - }, Commands.ShowQuickRepoStatus, [ - undefined, - { - goBackCommand - } as ShowQuickRepoStatusCommandArgs - ] - ); - - const computed = this.computeStatus(status.files); - if (computed.staged > 0) { - let index = 0; - const unstagedIndex = computed.unstaged > 0 ? status.files.findIndex(f => !f.staged) : -1; - if (unstagedIndex > -1) { - items.splice(unstagedIndex, 0, new CommandQuickPickItem({ - label: `Unstaged Files`, - description: computed.unstagedStatus - }, Commands.ShowQuickRepoStatus, [ - undefined, - { - goBackCommand - } as ShowQuickRepoStatusCommandArgs - ]) - ); - - items.splice(unstagedIndex, 0, new OpenStatusFilesCommandQuickPickItem(computed.stagedAddsAndChanges, { - label: `${GlyphChars.Space.repeat(4)} $(file-symlink-file) Open Staged Files`, - description: '' - })); - - items.push(new OpenStatusFilesCommandQuickPickItem(computed.unstagedAddsAndChanges, { - label: `${GlyphChars.Space.repeat(4)} $(file-symlink-file) Open Unstaged Files`, - description: '' - })); - } - - items.splice(index++, 0, new CommandQuickPickItem({ - label: `Staged Files`, - description: computed.stagedStatus - }, Commands.ShowQuickRepoStatus, [ - undefined, - { - goBackCommand - } as ShowQuickRepoStatusCommandArgs - ]) - ); - } - else if (status.files.some(f => !f.staged)) { - items.splice(0, 0, new CommandQuickPickItem({ - label: `Unstaged Files`, - description: computed.unstagedStatus - }, Commands.ShowQuickRepoStatus, [ - undefined, - { - goBackCommand - } as ShowQuickRepoStatusCommandArgs - ]) - ); - } - - if (status.files.length) { - items.push(new OpenStatusFilesCommandQuickPickItem(computed.stagedAddsAndChanges.concat(computed.unstagedAddsAndChanges))); - items.push(new CommandQuickPickItem({ - label: '$(x) Close Unchanged Files', - description: '' - }, Commands.CloseUnchangedFiles)); - } - else { - items.push(new CommandQuickPickItem({ - label: `No changes in the working tree`, - description: '' - }, Commands.ShowQuickRepoStatus, [ - undefined, - { - goBackCommand - } as ShowQuickRepoStatusCommandArgs - ]) - ); - } - - items.splice(0, 0, new CommandQuickPickItem({ - label: `$(inbox) Show Stashed Changes`, - description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows stashed changes in the repository` - }, Commands.ShowQuickStashList, [ - GitUri.fromRepoPath(status.repoPath), - { - goBackCommand: currentCommand - } as ShowQuickStashListCommandArgs - ]) - ); - - if (status.upstream && status.state.ahead) { - items.splice(0, 0, new CommandQuickPickItem({ - label: `$(cloud-upload)${GlyphChars.Space} ${status.state.ahead} Commit${status.state.ahead > 1 ? 's' : ''} ahead of ${GlyphChars.Space}$(git-branch) ${status.upstream}`, - description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows commits in ${GlyphChars.Space}$(git-branch) ${status.branch} but not ${GlyphChars.Space}$(git-branch) ${status.upstream}` - }, Commands.ShowQuickBranchHistory, [ - GitUri.fromRepoPath(status.repoPath, `${status.upstream}..${status.branch}`), - { - branch: status.branch, - maxCount: 0, - goBackCommand: currentCommand - } as ShowQuickBranchHistoryCommandArgs - ]) - ); - } - - if (status.upstream && status.state.behind) { - items.splice(0, 0, new CommandQuickPickItem({ - label: `$(cloud-download)${GlyphChars.Space} ${status.state.behind} Commit${status.state.behind > 1 ? 's' : ''} behind ${GlyphChars.Space}$(git-branch) ${status.upstream}`, - description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows commits in ${GlyphChars.Space}$(git-branch) ${status.upstream} but not ${GlyphChars.Space}$(git-branch) ${status.branch}${status.sha ? ` (since ${GlyphChars.Space}$(git-commit) ${GitService.shortenSha(status.sha)})` : ''}` - }, Commands.ShowQuickBranchHistory, [ - GitUri.fromRepoPath(status.repoPath, `${status.branch}..${status.upstream}`), - { - branch: status.upstream, - maxCount: 0, - goBackCommand: currentCommand - } as ShowQuickBranchHistoryCommandArgs - ]) - ); - } - - if (status.upstream && !status.state.ahead && !status.state.behind) { - items.splice(0, 0, new CommandQuickPickItem({ - label: `$(git-branch) ${status.branch} is up-to-date with ${GlyphChars.Space}$(git-branch) ${status.upstream}`, - description: '' - }, Commands.ShowQuickRepoStatus, [ - undefined, - { - goBackCommand - } as ShowQuickRepoStatusCommandArgs - ]) - ); - } - - if (goBackCommand) { - items.splice(0, 0, goBackCommand); - } - - const scope = await Container.keyboard.beginScope({ left: goBackCommand }); - - const pick = await window.showQuickPick(items, { - matchOnDescription: true, - placeHolder: `status of ${status.branch}${status.upstream ? ` ${Strings.pad(GlyphChars.ArrowLeftRight, 1, 1)} ${status.upstream}` : ''}`, - ignoreFocusOut: getQuickPickIgnoreFocusOut(), - onDidSelectItem: (item: QuickPickItem) => { - scope.setKeyCommand('right', item); - } - } as QuickPickOptions); - - await scope.dispose(); - - return pick; - } +'use strict'; +import { Iterables, Strings } from '../system'; +import { commands, QuickPickOptions, TextDocumentShowOptions, window } from 'vscode'; +import { Commands, DiffWithPreviousCommandArgs, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands'; +import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, QuickPickItem } from './commonQuickPicks'; +import { GlyphChars } from '../constants'; +import { Container } from '../container'; +import { GitCommitType, GitLogCommit, GitService, GitStatus, GitStatusFile, GitStatusFileStatus, GitUri } from '../gitService'; +import { Keys } from '../keyboard'; +import * as path from 'path'; + +export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem { + + public readonly status: GitStatusFile; + private readonly commit: GitLogCommit; + + constructor( + status: GitStatusFile, + realIndexStatus?: GitStatusFileStatus, + item?: QuickPickItem + ) { + const octicon = status.getOcticon(); + const description = status.getFormattedDirectory(true); + + super(status.uri, item || { + label: `${status.staged ? '$(check)' : GlyphChars.Space.repeat(3)}${Strings.pad(octicon, 2, 2)} ${path.basename(status.fileName)}`, + description: description + }); + + this.status = status; + if (status.indexStatus !== undefined) { + this.commit = new GitLogCommit(GitCommitType.File, status.repoPath, GitService.stagedUncommittedSha, 'You', undefined, new Date(), '', status.fileName, [status], status.status, status.originalFileName, 'HEAD', status.fileName); + } + else { + this.commit = new GitLogCommit(GitCommitType.File, status.repoPath, GitService.uncommittedSha, 'You', undefined, new Date(), '', status.fileName, [status], status.status, status.originalFileName, realIndexStatus !== undefined ? GitService.stagedUncommittedSha : 'HEAD', status.fileName); + } + } + + onDidPressKey(key: Keys): Promise<{} | undefined> { + return commands.executeCommand(Commands.DiffWithPrevious, + GitUri.fromFileStatus(this.status, this.status.repoPath), + { + commit: this.commit, + line: 0, + showOptions: { + preserveFocus: true, + preview: false + } as TextDocumentShowOptions + } as DiffWithPreviousCommandArgs) as Promise<{} | undefined>; + } +} + +export class OpenStatusFilesCommandQuickPickItem extends CommandQuickPickItem { + + constructor( + statuses: GitStatusFile[], + item?: QuickPickItem + ) { + const uris = statuses.map(f => f.uri); + + super(item || { + label: `$(file-symlink-file) Open Changed Files`, + description: '' + // detail: `Opens all of the changed files in the repository` + }, Commands.OpenChangedFiles, [ + undefined, + { + uris + } as OpenChangedFilesCommandArgs + ] + ); + } +} + +interface ComputedStatus { + staged: number; + stagedAddsAndChanges: GitStatusFile[]; + stagedStatus: string; + + unstaged: number; + unstagedAddsAndChanges: GitStatusFile[]; + unstagedStatus: string; +} + +export class RepoStatusQuickPick { + + private static computeStatus(files: GitStatusFile[]): ComputedStatus { + let stagedAdds = 0; + let unstagedAdds = 0; + let stagedChanges = 0; + let unstagedChanges = 0; + let stagedDeletes = 0; + let unstagedDeletes = 0; + + const stagedAddsAndChanges: GitStatusFile[] = []; + const unstagedAddsAndChanges: GitStatusFile[] = []; + + for (const f of files) { + switch (f.indexStatus) { + case 'A': + case '?': + stagedAdds++; + stagedAddsAndChanges.push(f); + break; + + case 'D': + stagedDeletes++; + break; + + case undefined: + break; + + default: + stagedChanges++; + stagedAddsAndChanges.push(f); + break; + } + + switch (f.workTreeStatus) { + case 'A': + case '?': + unstagedAdds++; + unstagedAddsAndChanges.push(f); + break; + + case 'D': + unstagedDeletes++; + break; + + case undefined: + break; + + default: + unstagedChanges++; + unstagedAddsAndChanges.push(f); + break; + } + } + + const staged = stagedAdds + stagedChanges + stagedDeletes; + const unstaged = unstagedAdds + unstagedChanges + unstagedDeletes; + + return { + staged: staged, + stagedStatus: staged > 0 ? `+${stagedAdds} ~${stagedChanges} -${stagedDeletes}` : '', + stagedAddsAndChanges: stagedAddsAndChanges, + unstaged: unstaged, + unstagedStatus: unstaged > 0 ? `+${unstagedAdds} ~${unstagedChanges} -${unstagedDeletes}` : '', + unstagedAddsAndChanges: unstagedAddsAndChanges + }; + } + + static async show(status: GitStatus, goBackCommand?: CommandQuickPickItem): Promise { + const items = [ + ...Iterables.flatMap(status.files, s => { + if (s.workTreeStatus !== undefined && s.indexStatus !== undefined) { + return [ + new OpenStatusFileCommandQuickPickItem(s.with({ indexStatus: null }), s.indexStatus), + new OpenStatusFileCommandQuickPickItem(s.with({ workTreeStatus: null })) + ]; + } + else { + return [new OpenStatusFileCommandQuickPickItem(s)]; + } + }) + ] as (OpenStatusFileCommandQuickPickItem | OpenStatusFilesCommandQuickPickItem | CommandQuickPickItem)[]; + + // Sort the status by staged and then filename + items.sort((a, b) => ((a as OpenStatusFileCommandQuickPickItem).status.staged ? -1 : 1) - ((b as OpenStatusFileCommandQuickPickItem).status.staged ? -1 : 1) || + (a as OpenStatusFileCommandQuickPickItem).status.fileName.localeCompare((b as OpenStatusFileCommandQuickPickItem).status.fileName)); + + const currentCommand = new CommandQuickPickItem({ + label: `go back ${GlyphChars.ArrowBack}`, + description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to ${GlyphChars.Space}$(git-branch) ${status.branch} status` + }, Commands.ShowQuickRepoStatus, [ + undefined, + { + goBackCommand + } as ShowQuickRepoStatusCommandArgs + ] + ); + + const computed = this.computeStatus(status.files); + if (computed.staged > 0) { + let index = 0; + const unstagedIndex = computed.unstaged > 0 ? status.files.findIndex(f => !f.staged) : -1; + if (unstagedIndex > -1) { + items.splice(unstagedIndex, 0, new CommandQuickPickItem({ + label: `Unstaged Files`, + description: computed.unstagedStatus + }, Commands.ShowQuickRepoStatus, [ + undefined, + { + goBackCommand + } as ShowQuickRepoStatusCommandArgs + ]) + ); + + items.splice(unstagedIndex, 0, new OpenStatusFilesCommandQuickPickItem(computed.stagedAddsAndChanges, { + label: `${GlyphChars.Space.repeat(4)} $(file-symlink-file) Open Staged Files`, + description: '' + })); + + items.push(new OpenStatusFilesCommandQuickPickItem(computed.unstagedAddsAndChanges, { + label: `${GlyphChars.Space.repeat(4)} $(file-symlink-file) Open Unstaged Files`, + description: '' + })); + } + + items.splice(index++, 0, new CommandQuickPickItem({ + label: `Staged Files`, + description: computed.stagedStatus + }, Commands.ShowQuickRepoStatus, [ + undefined, + { + goBackCommand + } as ShowQuickRepoStatusCommandArgs + ]) + ); + } + else if (status.files.some(f => !f.staged)) { + items.splice(0, 0, new CommandQuickPickItem({ + label: `Unstaged Files`, + description: computed.unstagedStatus + }, Commands.ShowQuickRepoStatus, [ + undefined, + { + goBackCommand + } as ShowQuickRepoStatusCommandArgs + ]) + ); + } + + if (status.files.length) { + items.push(new OpenStatusFilesCommandQuickPickItem(computed.stagedAddsAndChanges.concat(computed.unstagedAddsAndChanges))); + items.push(new CommandQuickPickItem({ + label: '$(x) Close Unchanged Files', + description: '' + }, Commands.CloseUnchangedFiles)); + } + else { + items.push(new CommandQuickPickItem({ + label: `No changes in the working tree`, + description: '' + }, Commands.ShowQuickRepoStatus, [ + undefined, + { + goBackCommand + } as ShowQuickRepoStatusCommandArgs + ]) + ); + } + + items.splice(0, 0, new CommandQuickPickItem({ + label: `$(inbox) Show Stashed Changes`, + description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows stashed changes in the repository` + }, Commands.ShowQuickStashList, [ + GitUri.fromRepoPath(status.repoPath), + { + goBackCommand: currentCommand + } as ShowQuickStashListCommandArgs + ]) + ); + + if (status.upstream && status.state.ahead) { + items.splice(0, 0, new CommandQuickPickItem({ + label: `$(cloud-upload)${GlyphChars.Space} ${status.state.ahead} Commit${status.state.ahead > 1 ? 's' : ''} ahead of ${GlyphChars.Space}$(git-branch) ${status.upstream}`, + description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows commits in ${GlyphChars.Space}$(git-branch) ${status.branch} but not ${GlyphChars.Space}$(git-branch) ${status.upstream}` + }, Commands.ShowQuickBranchHistory, [ + GitUri.fromRepoPath(status.repoPath, `${status.upstream}..${status.branch}`), + { + branch: status.branch, + maxCount: 0, + goBackCommand: currentCommand + } as ShowQuickBranchHistoryCommandArgs + ]) + ); + } + + if (status.upstream && status.state.behind) { + items.splice(0, 0, new CommandQuickPickItem({ + label: `$(cloud-download)${GlyphChars.Space} ${status.state.behind} Commit${status.state.behind > 1 ? 's' : ''} behind ${GlyphChars.Space}$(git-branch) ${status.upstream}`, + description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows commits in ${GlyphChars.Space}$(git-branch) ${status.upstream} but not ${GlyphChars.Space}$(git-branch) ${status.branch}${status.sha ? ` (since ${GlyphChars.Space}$(git-commit) ${GitService.shortenSha(status.sha)})` : ''}` + }, Commands.ShowQuickBranchHistory, [ + GitUri.fromRepoPath(status.repoPath, `${status.branch}..${status.upstream}`), + { + branch: status.upstream, + maxCount: 0, + goBackCommand: currentCommand + } as ShowQuickBranchHistoryCommandArgs + ]) + ); + } + + if (status.upstream && !status.state.ahead && !status.state.behind) { + items.splice(0, 0, new CommandQuickPickItem({ + label: `$(git-branch) ${status.branch} is up-to-date with ${GlyphChars.Space}$(git-branch) ${status.upstream}`, + description: '' + }, Commands.ShowQuickRepoStatus, [ + undefined, + { + goBackCommand + } as ShowQuickRepoStatusCommandArgs + ]) + ); + } + + if (goBackCommand) { + items.splice(0, 0, goBackCommand); + } + + const scope = await Container.keyboard.beginScope({ left: goBackCommand }); + + const pick = await window.showQuickPick(items, { + matchOnDescription: true, + placeHolder: `status of ${status.branch}${status.upstream ? ` ${Strings.pad(GlyphChars.ArrowLeftRight, 1, 1)} ${status.upstream}` : ''}`, + ignoreFocusOut: getQuickPickIgnoreFocusOut(), + onDidSelectItem: (item: QuickPickItem) => { + scope.setKeyCommand('right', item); + } + } as QuickPickOptions); + + await scope.dispose(); + + return pick; + } } \ No newline at end of file diff --git a/src/quickPicks/repositories.ts b/src/quickPicks/repositoriesQuickPick.ts similarity index 98% rename from src/quickPicks/repositories.ts rename to src/quickPicks/repositoriesQuickPick.ts index e06eb6f..5f4fa72 100644 --- a/src/quickPicks/repositories.ts +++ b/src/quickPicks/repositoriesQuickPick.ts @@ -1,9 +1,9 @@ 'use strict'; import { Iterables } from '../system'; import { QuickPickItem, QuickPickOptions, window } from 'vscode'; +import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './commonQuickPicks'; import { Container } from '../container'; import { Repository } from '../gitService'; -import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from '../quickPicks'; export class RepositoryQuickPickItem implements QuickPickItem { diff --git a/src/quickPicks/stashList.ts b/src/quickPicks/stashListQuickPick.ts similarity index 97% rename from src/quickPicks/stashList.ts rename to src/quickPicks/stashListQuickPick.ts index 7c28a7b..846eb14 100644 --- a/src/quickPicks/stashList.ts +++ b/src/quickPicks/stashListQuickPick.ts @@ -6,7 +6,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitStash } from '../gitService'; import { KeyNoopCommand } from '../keyboard'; -import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from '../quickPicks'; +import { CommandQuickPickItem, CommitQuickPickItem, getQuickPickIgnoreFocusOut, showQuickPickProgress } from '../quickPicks/quickPicks'; export class StashListQuickPick {