Browse Source

Splits GitActions into separate modules

Removes more namespaces for better tree-shaking
main
Eric Amodio 2 years ago
parent
commit
ffa08d71d4
41 changed files with 1304 additions and 1293 deletions
  1. +1
    -1
      src/commands/addAuthors.ts
  2. +4
    -4
      src/commands/copyMessageToClipboard.ts
  3. +8
    -3
      src/commands/ghpr/createWorktree.ts
  4. +2
    -2
      src/commands/git/log.ts
  5. +2
    -2
      src/commands/git/remote.ts
  6. +2
    -2
      src/commands/git/search.ts
  7. +5
    -5
      src/commands/git/stash.ts
  8. +11
    -7
      src/commands/git/worktree.ts
  9. +0
    -1061
      src/commands/gitCommands.actions.ts
  10. +2
    -2
      src/commands/openDirectoryCompare.ts
  11. +4
    -4
      src/commands/openFileAtRevision.ts
  12. +3
    -3
      src/commands/openFileAtRevisionFrom.ts
  13. +2
    -2
      src/commands/openRevisionFile.ts
  14. +70
    -57
      src/commands/quickCommand.steps.ts
  15. +1
    -1
      src/commands/repositories.ts
  16. +1
    -1
      src/commands/searchCommits.ts
  17. +3
    -4
      src/commands/showCommitsInView.ts
  18. +1
    -1
      src/commands/showQuickBranchHistory.ts
  19. +3
    -2
      src/commands/showQuickCommit.ts
  20. +1
    -1
      src/commands/showQuickCommitFile.ts
  21. +1
    -1
      src/commands/showQuickFileHistory.ts
  22. +1
    -1
      src/commands/showQuickRepoStatus.ts
  23. +1
    -1
      src/commands/showQuickStashList.ts
  24. +3
    -3
      src/commands/stashApply.ts
  25. +2
    -2
      src/commands/stashSave.ts
  26. +26
    -0
      src/git/actions.ts
  27. +58
    -0
      src/git/actions/branch.ts
  28. +600
    -0
      src/git/actions/commit.ts
  29. +29
    -0
      src/git/actions/contributor.ts
  30. +70
    -0
      src/git/actions/remote.ts
  31. +84
    -0
      src/git/actions/repository.ts
  32. +65
    -0
      src/git/actions/stash.ts
  33. +45
    -0
      src/git/actions/tag.ts
  34. +50
    -0
      src/git/actions/worktree.ts
  35. +31
    -26
      src/plus/webviews/graph/graphWebview.ts
  36. +2
    -2
      src/plus/webviews/timeline/timelineWebview.ts
  37. +22
    -21
      src/quickpicks/items/commits.ts
  38. +6
    -4
      src/quickpicks/referencePicker.ts
  39. +1
    -1
      src/views/nodes/searchResultsNode.ts
  40. +67
    -59
      src/views/viewCommands.ts
  41. +14
    -7
      src/webviews/commitDetails/commitDetailsWebviewView.ts

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

@ -1,9 +1,9 @@
import type { SourceControl } from 'vscode'; import type { SourceControl } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { command } from '../system/command'; import { command } from '../system/command';
import { Command } from './base'; import { Command } from './base';
import { executeGitCommand } from './gitCommands.actions';
@command() @command()
export class AddAuthorsCommand extends Command { export class AddAuthorsCommand extends Command {

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

@ -2,6 +2,7 @@ import type { TextEditor, Uri } from 'vscode';
import { env } from 'vscode'; import { env } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { copyMessageToClipboard } from '../git/actions/commit';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages'; import { showGenericErrorMessage } from '../messages';
@ -15,7 +16,6 @@ import {
isCommandContextViewNodeHasCommit, isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasTag, isCommandContextViewNodeHasTag,
} from './base'; } from './base';
import { GitActions } from './gitCommands.actions';
export interface CopyMessageToClipboardCommandArgs { export interface CopyMessageToClipboardCommandArgs {
message?: string; message?: string;
@ -62,7 +62,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
try { try {
if (!args.message) { if (!args.message) {
if (args.repoPath != null && args.sha != null) { if (args.repoPath != null && args.sha != null) {
await GitActions.Commit.copyMessageToClipboard({ ref: args.sha, repoPath: args.repoPath });
await copyMessageToClipboard({ ref: args.sha, repoPath: args.repoPath });
return; return;
} }
@ -92,7 +92,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
const blame = await this.container.git.getBlameForLine(gitUri, blameline, editor?.document); const blame = await this.container.git.getBlameForLine(gitUri, blameline, editor?.document);
if (blame == null || blame.commit.isUncommitted) return; if (blame == null || blame.commit.isUncommitted) return;
await GitActions.Commit.copyMessageToClipboard(blame.commit);
await copyMessageToClipboard(blame.commit);
return; return;
} catch (ex) { } catch (ex) {
Logger.error(ex, 'CopyMessageToClipboardCommand', `getBlameForLine(${blameline})`); Logger.error(ex, 'CopyMessageToClipboardCommand', `getBlameForLine(${blameline})`);
@ -101,7 +101,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
return; return;
} }
} else { } else {
await GitActions.Commit.copyMessageToClipboard({ ref: args.sha, repoPath: repoPath! });
await copyMessageToClipboard({ ref: args.sha, repoPath: repoPath! });
return; return;
} }
} }

+ 8
- 3
src/commands/ghpr/createWorktree.ts View File

@ -2,13 +2,14 @@ import type { Uri } from 'vscode';
import { window } from 'vscode'; import { window } from 'vscode';
import { Commands } from '../../constants'; import { Commands } from '../../constants';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { add as addRemote } from '../../git/actions/remote';
import { create as createWorktree } from '../../git/actions/worktree';
import { GitReference } from '../../git/models/reference'; import { GitReference } from '../../git/models/reference';
import type { GitRemote } from '../../git/models/remote'; import type { GitRemote } from '../../git/models/remote';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
import { command } from '../../system/command'; import { command } from '../../system/command';
import { waitUntilNextTick } from '../../system/promise'; import { waitUntilNextTick } from '../../system/promise';
import { Command } from '../base'; import { Command } from '../base';
import { GitActions } from '../gitCommands.actions';
interface PullRequestNode { interface PullRequestNode {
readonly pullRequestModel: PullRequest; readonly pullRequestModel: PullRequest;
@ -90,7 +91,11 @@ export class CreateWorktreeCommand extends Command {
); );
if (result?.title !== 'Yes') return; if (result?.title !== 'Yes') return;
await GitActions.Remote.add(repo, remoteOwner, remoteUrl, { confirm: false, fetch: true, reveal: false });
await addRemote(repo, remoteOwner, remoteUrl, {
confirm: false,
fetch: true,
reveal: false,
});
[remote] = await repo.getRemotes({ filter: r => r.url === remoteUrl }); [remote] = await repo.getRemotes({ filter: r => r.url === remoteUrl });
if (remote == null) return; if (remote == null) return;
} else { } else {
@ -100,7 +105,7 @@ export class CreateWorktreeCommand extends Command {
await waitUntilNextTick(); await waitUntilNextTick();
try { try {
await GitActions.Worktree.create(
await createWorktree(
repo, repo,
undefined, undefined,
GitReference.create(`${remote.name}/${ref}`, repo.path, { GitReference.create(`${remote.name}/${ref}`, repo.path, {

+ 2
- 2
src/commands/git/log.ts View File

@ -1,5 +1,6 @@
import { GlyphChars, quickPickTitleMaxChars } from '../../constants'; import { GlyphChars, quickPickTitleMaxChars } from '../../constants';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { showDetailsView } from '../../git/actions/commit';
import { GitCommit } from '../../git/models/commit'; import { GitCommit } from '../../git/models/commit';
import type { GitLog } from '../../git/models/log'; import type { GitLog } from '../../git/models/log';
import { GitReference } from '../../git/models/reference'; import { GitReference } from '../../git/models/reference';
@ -7,7 +8,6 @@ import { Repository } from '../../git/models/repository';
import { formatPath } from '../../system/formatPath'; import { formatPath } from '../../system/formatPath';
import { pad } from '../../system/string'; import { pad } from '../../system/string';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitActions } from '../gitCommands.actions';
import { getSteps } from '../gitCommands.utils'; import { getSteps } from '../gitCommands.utils';
import type { PartialStepState, StepGenerator } from '../quickCommand'; import type { PartialStepState, StepGenerator } from '../quickCommand';
import { pickBranchOrTagStep, pickCommitStep, pickRepositoryStep, QuickCommand, StepResult } from '../quickCommand'; import { pickBranchOrTagStep, pickCommitStep, pickRepositoryStep, QuickCommand, StepResult } from '../quickCommand';
@ -191,7 +191,7 @@ export class LogGitCommand extends QuickCommand {
let result: StepResult<ReturnType<typeof getSteps>>; let result: StepResult<ReturnType<typeof getSteps>>;
if (state.openPickInView) { if (state.openPickInView) {
void GitActions.Commit.showDetailsView(state.reference as GitCommit, {
void showDetailsView(state.reference as GitCommit, {
pin: false, pin: false,
preserveFocus: false, preserveFocus: false,
}); });

+ 2
- 2
src/commands/git/remote.ts View File

@ -1,6 +1,7 @@
import type { QuickPickItem } from 'vscode'; import type { QuickPickItem } from 'vscode';
import { QuickInputButtons } from 'vscode'; import { QuickInputButtons } from 'vscode';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { reveal } from '../../git/actions/remote';
import type { GitRemote } from '../../git/models/remote'; import type { GitRemote } from '../../git/models/remote';
import { Repository } from '../../git/models/repository'; import { Repository } from '../../git/models/repository';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
@ -8,7 +9,6 @@ import { showGenericErrorMessage } from '../../messages';
import type { QuickPickItemOfT } from '../../quickpicks/items/common'; import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags'; import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitActions } from '../gitCommands.actions';
import type { import type {
AsyncStepResultGenerator, AsyncStepResultGenerator,
PartialStepState, PartialStepState,
@ -320,7 +320,7 @@ export class RemoteGitCommand extends QuickCommand {
await state.repo.addRemote(state.name, state.url, state.flags.includes('-f') ? { fetch: true } : undefined); await state.repo.addRemote(state.name, state.url, state.flags.includes('-f') ? { fetch: true } : undefined);
if (state.reveal !== false) { if (state.reveal !== false) {
void GitActions.Remote.reveal(undefined, {
void reveal(undefined, {
focus: true, focus: true,
select: true, select: true,
}); });

+ 2
- 2
src/commands/git/search.ts View File

@ -2,6 +2,7 @@ import { configuration } from '../../configuration';
import { ContextKeys, GlyphChars } from '../../constants'; import { ContextKeys, GlyphChars } from '../../constants';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { getContext } from '../../context'; import { getContext } from '../../context';
import { showDetailsView } from '../../git/actions/commit';
import type { GitCommit } from '../../git/models/commit'; import type { GitCommit } from '../../git/models/commit';
import type { GitLog } from '../../git/models/log'; import type { GitLog } from '../../git/models/log';
import type { Repository } from '../../git/models/repository'; import type { Repository } from '../../git/models/repository';
@ -12,7 +13,6 @@ import { ActionQuickPickItem } from '../../quickpicks/items/common';
import { pluralize } from '../../system/string'; import { pluralize } from '../../system/string';
import { SearchResultsNode } from '../../views/nodes/searchResultsNode'; import { SearchResultsNode } from '../../views/nodes/searchResultsNode';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitActions } from '../gitCommands.actions';
import { getSteps } from '../gitCommands.utils'; import { getSteps } from '../gitCommands.utils';
import type { PartialStepState, StepGenerator, StepResultGenerator, StepSelection, StepState } from '../quickCommand'; import type { PartialStepState, StepGenerator, StepResultGenerator, StepSelection, StepState } from '../quickCommand';
import { import {
@ -245,7 +245,7 @@ export class SearchGitCommand extends QuickCommand {
let result: StepResult<ReturnType<typeof getSteps>>; let result: StepResult<ReturnType<typeof getSteps>>;
if (state.openPickInView) { if (state.openPickInView) {
void GitActions.Commit.showDetailsView(context.commit, {
void showDetailsView(context.commit, {
pin: false, pin: false,
preserveFocus: false, preserveFocus: false,
}); });

+ 5
- 5
src/commands/git/stash.ts View File

@ -3,6 +3,7 @@ import { QuickInputButtons, window } from 'vscode';
import { ContextKeys, GlyphChars } from '../../constants'; import { ContextKeys, GlyphChars } from '../../constants';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { getContext } from '../../context'; import { getContext } from '../../context';
import { reveal, showDetailsView } from '../../git/actions/stash';
import { StashApplyError, StashApplyErrorReason } from '../../git/errors'; import { StashApplyError, StashApplyErrorReason } from '../../git/errors';
import type { GitStashCommit } from '../../git/models/commit'; import type { GitStashCommit } from '../../git/models/commit';
import type { GitStashReference } from '../../git/models/reference'; import type { GitStashReference } from '../../git/models/reference';
@ -15,7 +16,6 @@ import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { formatPath } from '../../system/formatPath'; import { formatPath } from '../../system/formatPath';
import { pad } from '../../system/string'; import { pad } from '../../system/string';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitActions } from '../gitCommands.actions';
import { getSteps } from '../gitCommands.utils'; import { getSteps } from '../gitCommands.utils';
import type { import type {
AsyncStepResultGenerator, AsyncStepResultGenerator,
@ -367,12 +367,12 @@ export class StashGitCommand extends QuickCommand {
additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar], additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
onDidClickButton: (quickpick, button) => { onDidClickButton: (quickpick, button) => {
if (button === QuickCommandButtons.ShowDetailsView) { if (button === QuickCommandButtons.ShowDetailsView) {
void GitActions.Stash.showDetailsView(state.reference, {
void showDetailsView(state.reference, {
pin: false, pin: false,
preserveFocus: true, preserveFocus: true,
}); });
} else if (button === QuickCommandButtons.RevealInSideBar) { } else if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Stash.reveal(state.reference, {
void reveal(state.reference, {
select: true, select: true,
expand: true, expand: true,
}); });
@ -431,12 +431,12 @@ export class StashGitCommand extends QuickCommand {
additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar], additionalButtons: [QuickCommandButtons.ShowDetailsView, QuickCommandButtons.RevealInSideBar],
onDidClickButton: (quickpick, button) => { onDidClickButton: (quickpick, button) => {
if (button === QuickCommandButtons.ShowDetailsView) { if (button === QuickCommandButtons.ShowDetailsView) {
void GitActions.Stash.showDetailsView(state.reference, {
void showDetailsView(state.reference, {
pin: false, pin: false,
preserveFocus: true, preserveFocus: true,
}); });
} else if (button === QuickCommandButtons.RevealInSideBar) { } else if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Stash.reveal(state.reference, {
void reveal(state.reference, {
select: true, select: true,
expand: true, expand: true,
}); });

+ 11
- 7
src/commands/git/worktree.ts View File

@ -4,6 +4,7 @@ import type { Config } from '../../configuration';
import { configuration } from '../../configuration'; import { configuration } from '../../configuration';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { PlusFeatures } from '../../features'; import { PlusFeatures } from '../../features';
import { open, reveal, revealInFileExplorer } from '../../git/actions/worktree';
import { import {
WorktreeCreateError, WorktreeCreateError,
WorktreeCreateErrorReason, WorktreeCreateErrorReason,
@ -22,7 +23,6 @@ import { basename, isDescendent } from '../../system/path';
import { pluralize, truncateLeft } from '../../system/string'; import { pluralize, truncateLeft } from '../../system/string';
import { OpenWorkspaceLocation } from '../../system/utils'; import { OpenWorkspaceLocation } from '../../system/utils';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitActions } from '../gitCommands.actions';
import type { import type {
AsyncStepResultGenerator, AsyncStepResultGenerator,
CustomStep, CustomStep,
@ -386,7 +386,7 @@ export class WorktreeGitCommand extends QuickCommand {
}); });
if (state.reveal !== false) { if (state.reveal !== false) {
void GitActions.Worktree.reveal(undefined, {
void reveal(undefined, {
select: true, select: true,
focus: true, focus: true,
}); });
@ -426,13 +426,17 @@ export class WorktreeGitCommand extends QuickCommand {
switch (action) { switch (action) {
case 'always': case 'always':
GitActions.Worktree.open(worktree, { location: OpenWorkspaceLocation.CurrentWindow });
open(worktree, {
location: OpenWorkspaceLocation.CurrentWindow,
});
break; break;
case 'alwaysNewWindow': case 'alwaysNewWindow':
GitActions.Worktree.open(worktree, { location: OpenWorkspaceLocation.NewWindow });
open(worktree, { location: OpenWorkspaceLocation.NewWindow });
break; break;
case 'addToWorkspace': case 'addToWorkspace':
GitActions.Worktree.open(worktree, { location: OpenWorkspaceLocation.AddToWorkspace });
open(worktree, {
location: OpenWorkspaceLocation.AddToWorkspace,
});
break; break;
} }
}); });
@ -797,9 +801,9 @@ export class WorktreeGitCommand extends QuickCommand {
const worktree = context.worktrees.find(wt => wt.uri.toString() === state.uri.toString())!; const worktree = context.worktrees.find(wt => wt.uri.toString() === state.uri.toString())!;
if (state.flags.includes('--reveal-explorer')) { if (state.flags.includes('--reveal-explorer')) {
void GitActions.Worktree.revealInFileExplorer(worktree);
void revealInFileExplorer(worktree);
} else { } else {
GitActions.Worktree.open(worktree, {
open(worktree, {
location: state.flags.includes('--new-window') location: state.flags.includes('--new-window')
? OpenWorkspaceLocation.NewWindow ? OpenWorkspaceLocation.NewWindow
: OpenWorkspaceLocation.CurrentWindow, : OpenWorkspaceLocation.CurrentWindow,

+ 0
- 1061
src/commands/gitCommands.actions.ts
File diff suppressed because it is too large
View File


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

@ -1,6 +1,7 @@
import type { TextEditor, Uri } from 'vscode'; import type { TextEditor, Uri } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { openDirectoryCompare } from '../git/actions/commit';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages'; import { showGenericErrorMessage } from '../messages';
import { ReferencePicker } from '../quickpicks/referencePicker'; import { ReferencePicker } from '../quickpicks/referencePicker';
@ -9,7 +10,6 @@ import { command } from '../system/command';
import { CompareResultsNode } from '../views/nodes/compareResultsNode'; import { CompareResultsNode } from '../views/nodes/compareResultsNode';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasRef } from './base'; import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasRef } from './base';
import { GitActions } from './gitCommands.actions';
export interface OpenDirectoryCompareCommandArgs { export interface OpenDirectoryCompareCommandArgs {
ref1?: string; ref1?: string;
@ -80,7 +80,7 @@ export class OpenDirectoryCompareCommand extends ActiveEditorCommand {
if (args.ref1 == null) return; if (args.ref1 == null) return;
} }
void GitActions.Commit.openDirectoryCompare(repoPath, args.ref1, args.ref2);
void openDirectoryCompare(repoPath, args.ref1, args.ref2);
} catch (ex) { } catch (ex) {
Logger.error(ex, 'OpenDirectoryCompareCommand'); Logger.error(ex, 'OpenDirectoryCompareCommand');
void showGenericErrorMessage('Unable to open directory compare'); void showGenericErrorMessage('Unable to open directory compare');

+ 4
- 4
src/commands/openFileAtRevision.ts View File

@ -3,6 +3,7 @@ import { Uri } from 'vscode';
import { FileAnnotationType } from '../configuration'; import { FileAnnotationType } from '../configuration';
import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants'; import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { openFileAtRevision } from '../git/actions/commit';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models/reference'; import { GitRevision } from '../git/models/reference';
import { Logger } from '../logger'; import { Logger } from '../logger';
@ -13,7 +14,6 @@ import { command } from '../system/command';
import { pad } from '../system/string'; import { pad } from '../system/string';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { ActiveEditorCommand, getCommandUri } from './base'; import { ActiveEditorCommand, getCommandUri } from './base';
import { GitActions } from './gitCommands.actions';
import type { OpenFileAtRevisionFromCommandArgs } from './openFileAtRevisionFrom'; import type { OpenFileAtRevisionFromCommandArgs } from './openFileAtRevisionFrom';
export interface OpenFileAtRevisionCommandArgs { export interface OpenFileAtRevisionCommandArgs {
@ -135,7 +135,7 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand {
picked: gitUri.sha, picked: gitUri.sha,
keys: ['right', 'alt+right', 'ctrl+right'], keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async (key, item) => { onDidPressKey: async (key, item) => {
await GitActions.Commit.openFileAtRevision(item.item.file!, item.item, {
await openFileAtRevision(item.item.file!, item.item, {
annotationType: args!.annotationType, annotationType: args!.annotationType,
line: args!.line, line: args!.line,
preserveFocus: true, preserveFocus: true,
@ -157,7 +157,7 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand {
); );
if (pick?.file == null) return; if (pick?.file == null) return;
await GitActions.Commit.openFileAtRevision(pick.file, pick, {
await openFileAtRevision(pick.file, pick, {
annotationType: args.annotationType, annotationType: args.annotationType,
line: args.line, line: args.line,
...args.showOptions, ...args.showOptions,
@ -166,7 +166,7 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand {
return; return;
} }
await GitActions.Commit.openFileAtRevision(args.revisionUri, {
await openFileAtRevision(args.revisionUri, {
annotationType: args.annotationType, annotationType: args.annotationType,
line: args.line, line: args.line,
...args.showOptions, ...args.showOptions,

+ 3
- 3
src/commands/openFileAtRevisionFrom.ts View File

@ -2,6 +2,7 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import type { FileAnnotationType } from '../configuration'; import type { FileAnnotationType } from '../configuration';
import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants'; import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { openFileAtRevision } from '../git/actions/commit';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import type { GitReference } from '../git/models/reference'; import type { GitReference } from '../git/models/reference';
import { showNoRepositoryWarningMessage } from '../messages'; import { showNoRepositoryWarningMessage } from '../messages';
@ -10,7 +11,6 @@ import { ReferencePicker } from '../quickpicks/referencePicker';
import { command } from '../system/command'; import { command } from '../system/command';
import { pad } from '../system/string'; import { pad } from '../system/string';
import { ActiveEditorCommand, getCommandUri } from './base'; import { ActiveEditorCommand, getCommandUri } from './base';
import { GitActions } from './gitCommands.actions';
export interface OpenFileAtRevisionFromCommandArgs { export interface OpenFileAtRevisionFromCommandArgs {
reference?: GitReference; reference?: GitReference;
@ -69,7 +69,7 @@ export class OpenFileAtRevisionFromCommand extends ActiveEditorCommand {
onDidPressKey: async (key, quickpick) => { onDidPressKey: async (key, quickpick) => {
const [item] = quickpick.activeItems; const [item] = quickpick.activeItems;
if (item != null) { if (item != null) {
await GitActions.Commit.openFileAtRevision(
await openFileAtRevision(
this.container.git.getRevisionUri(item.ref, gitUri.fsPath, gitUri.repoPath!), this.container.git.getRevisionUri(item.ref, gitUri.fsPath, gitUri.repoPath!),
{ {
annotationType: args!.annotationType, annotationType: args!.annotationType,
@ -88,7 +88,7 @@ export class OpenFileAtRevisionFromCommand extends ActiveEditorCommand {
} }
} }
await GitActions.Commit.openFileAtRevision(
await openFileAtRevision(
this.container.git.getRevisionUri(args.reference.ref, gitUri.fsPath, gitUri.repoPath), this.container.git.getRevisionUri(args.reference.ref, gitUri.fsPath, gitUri.repoPath),
{ {
annotationType: args.annotationType, annotationType: args.annotationType,

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

@ -2,13 +2,13 @@ import type { TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import type { FileAnnotationType } from '../configuration'; import type { FileAnnotationType } from '../configuration';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { openFileAtRevision } from '../git/actions/commit';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models/reference'; import { GitRevision } from '../git/models/reference';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages'; import { showGenericErrorMessage } from '../messages';
import { command } from '../system/command'; import { command } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base'; import { ActiveEditorCommand, getCommandUri } from './base';
import { GitActions } from './gitCommands.actions';
export interface OpenRevisionFileCommandArgs { export interface OpenRevisionFileCommandArgs {
revisionUri?: Uri; revisionUri?: Uri;
@ -53,7 +53,7 @@ export class OpenRevisionFileCommand extends ActiveEditorCommand {
} }
} }
await GitActions.Commit.openFileAtRevision(args.revisionUri, {
await openFileAtRevision(args.revisionUri, {
annotationType: args.annotationType, annotationType: args.annotationType,
line: args.line, line: args.line,
...args.showOptions, ...args.showOptions,

+ 70
- 57
src/commands/quickCommand.steps.ts View File

@ -3,6 +3,14 @@ import { BranchSorting, configuration, TagSorting } from '../configuration';
import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants'; import { Commands, GlyphChars, quickPickTitleMaxChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import type { PlusFeatures } from '../features'; import type { PlusFeatures } from '../features';
import * as BranchActions from '../git/actions/branch';
import * as CommitActions from '../git/actions/commit';
import * as ContributorActions from '../git/actions/contributor';
import * as RemoteActions from '../git/actions/remote';
import * as RepositoryActions from '../git/actions/repository';
import * as StashActions from '../git/actions/stash';
import * as TagActions from '../git/actions/tag';
import * as WorktreeActions from '../git/actions/worktree';
import type { PagedResult } from '../git/gitProvider'; import type { PagedResult } from '../git/gitProvider';
import type { BranchSortOptions, GitBranch } from '../git/models/branch'; import type { BranchSortOptions, GitBranch } from '../git/models/branch';
import { sortBranches } from '../git/models/branch'; import { sortBranches } from '../git/models/branch';
@ -81,7 +89,6 @@ import { getSettledValue } from '../system/promise';
import { pad, pluralize, truncate } from '../system/string'; import { pad, pluralize, truncate } from '../system/string';
import { OpenWorkspaceLocation } from '../system/utils'; import { OpenWorkspaceLocation } from '../system/utils';
import type { ViewsWithRepositoryFolders } from '../views/viewBase'; import type { ViewsWithRepositoryFolders } from '../views/viewBase';
import { GitActions } from './gitCommands.actions';
import type { import type {
AsyncStepResultGenerator, AsyncStepResultGenerator,
PartialStepState, PartialStepState,
@ -677,14 +684,14 @@ export async function* pickBranchStep<
: branches, : branches,
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Branch.reveal(item, { select: true, focus: false, expand: true });
void BranchActions.reveal(item, { select: true, focus: false, expand: true });
} }
}, },
keys: ['right', 'alt+right', 'ctrl+right'], keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async quickpick => { onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
await GitActions.Branch.reveal(quickpick.activeItems[0].item, {
await BranchActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -733,14 +740,14 @@ export async function* pickBranchesStep<
: branches, : branches,
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Branch.reveal(item, { select: true, focus: false, expand: true });
void BranchActions.reveal(item, { select: true, focus: false, expand: true });
} }
}, },
keys: ['right', 'alt+right', 'ctrl+right'], keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async quickpick => { onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
await GitActions.Branch.reveal(quickpick.activeItems[0].item, {
await BranchActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -817,11 +824,11 @@ export async function* pickBranchOrTagStep<
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
if (GitReference.isBranch(item)) { if (GitReference.isBranch(item)) {
void GitActions.Branch.reveal(item, { select: true, focus: false, expand: true });
void BranchActions.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isTag(item)) { } else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, focus: false, expand: true });
void TagActions.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isRevision(item)) { } else if (GitReference.isRevision(item)) {
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(item, { pin: false, preserveFocus: true });
} }
} }
return false; return false;
@ -853,11 +860,11 @@ export async function* pickBranchOrTagStep<
const item = quickpick.activeItems[0].item; const item = quickpick.activeItems[0].item;
if (GitReference.isBranch(item)) { if (GitReference.isBranch(item)) {
void GitActions.Branch.reveal(item, { select: true, focus: false, expand: true });
void BranchActions.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isTag(item)) { } else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, focus: false, expand: true });
void TagActions.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isRevision(item)) { } else if (GitReference.isRevision(item)) {
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(item, { pin: false, preserveFocus: true });
} }
}, },
onValidateValue: getValidateGitReferenceFn(state.repo, { ranges: ranges }), onValidateValue: getValidateGitReferenceFn(state.repo, { ranges: ranges }),
@ -925,11 +932,11 @@ export async function* pickBranchOrTagStepMultiRepo<
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
if (GitReference.isBranch(item)) { if (GitReference.isBranch(item)) {
void GitActions.Branch.reveal(item, { select: true, focus: false, expand: true });
void BranchActions.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isTag(item)) { } else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, focus: false, expand: true });
void TagActions.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isRevision(item)) { } else if (GitReference.isRevision(item)) {
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(item, { pin: false, preserveFocus: true });
} }
} }
}, },
@ -966,11 +973,11 @@ export async function* pickBranchOrTagStepMultiRepo<
const item = quickpick.activeItems[0].item; const item = quickpick.activeItems[0].item;
if (GitReference.isBranch(item)) { if (GitReference.isBranch(item)) {
void GitActions.Branch.reveal(item, { select: true, focus: false, expand: true });
void BranchActions.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isTag(item)) { } else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, focus: false, expand: true });
void TagActions.reveal(item, { select: true, focus: false, expand: true });
} else if (GitReference.isRevision(item)) { } else if (GitReference.isRevision(item)) {
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(item, { pin: false, preserveFocus: true });
} }
}, },
onValidateValue: getValidateGitReferenceFn(state.repos), onValidateValue: getValidateGitReferenceFn(state.repos),
@ -1056,11 +1063,11 @@ export async function* pickCommitStep<
switch (button) { switch (button) {
case QuickCommandButtons.ShowDetailsView: case QuickCommandButtons.ShowDetailsView:
void GitActions.Commit.showDetailsView(item.item, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(item.item, { pin: false, preserveFocus: true });
break; break;
case QuickCommandButtons.RevealInSideBar: case QuickCommandButtons.RevealInSideBar:
void GitActions.Commit.reveal(item.item, {
void CommitActions.reveal(item.item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1088,9 +1095,9 @@ export async function* pickCommitStep<
); );
if (key === 'ctrl+right') { if (key === 'ctrl+right') {
void GitActions.Commit.showDetailsView(items[0].item, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(items[0].item, { pin: false, preserveFocus: true });
} else { } else {
await GitActions.Commit.reveal(items[0].item, {
await CommitActions.reveal(items[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1175,11 +1182,11 @@ export function* pickCommitsStep<
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
switch (button) { switch (button) {
case QuickCommandButtons.ShowDetailsView: case QuickCommandButtons.ShowDetailsView:
void GitActions.Commit.showDetailsView(item, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(item, { pin: false, preserveFocus: true });
break; break;
case QuickCommandButtons.RevealInSideBar: case QuickCommandButtons.RevealInSideBar:
void GitActions.Commit.reveal(item, {
void CommitActions.reveal(item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1192,12 +1199,12 @@ export function* pickCommitsStep<
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
if (key === 'ctrl+right') { if (key === 'ctrl+right') {
void GitActions.Commit.showDetailsView(quickpick.activeItems[0].item, {
void CommitActions.showDetailsView(quickpick.activeItems[0].item, {
pin: false, pin: false,
preserveFocus: true, preserveFocus: true,
}); });
} else { } else {
await GitActions.Commit.reveal(quickpick.activeItems[0].item, {
await CommitActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1232,14 +1239,14 @@ export async function* pickContributorsStep<
), ),
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Contributor.reveal(item, { select: true, focus: false, expand: true });
void ContributorActions.reveal(item, { select: true, focus: false, expand: true });
} }
}, },
keys: ['right', 'alt+right', 'ctrl+right'], keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: quickpick => { onDidPressKey: quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
void GitActions.Contributor.reveal(quickpick.activeItems[0].item, {
void ContributorActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1284,14 +1291,14 @@ export async function* pickRemoteStep<
: remotes, : remotes,
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Remote.reveal(item, { select: true, focus: false, expand: true });
void RemoteActions.reveal(item, { select: true, focus: false, expand: true });
} }
}, },
keys: ['right', 'alt+right', 'ctrl+right'], keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async quickpick => { onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
await GitActions.Remote.reveal(quickpick.activeItems[0].item, {
await RemoteActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1337,14 +1344,14 @@ export async function* pickRemotesStep<
: remotes, : remotes,
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Remote.reveal(item, { select: true, focus: false, expand: true });
void RemoteActions.reveal(item, { select: true, focus: false, expand: true });
} }
}, },
keys: ['right', 'alt+right', 'ctrl+right'], keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async quickpick => { onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
await GitActions.Remote.reveal(quickpick.activeItems[0].item, {
await RemoteActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1383,7 +1390,7 @@ export async function* pickRepositoryStep<
), ),
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Repo.reveal(item.path, context.associatedView, {
void RepositoryActions.reveal(item.path, context.associatedView, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1394,7 +1401,7 @@ export async function* pickRepositoryStep<
onDidPressKey: quickpick => { onDidPressKey: quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
void GitActions.Repo.reveal(quickpick.activeItems[0].item.path, context.associatedView, {
void RepositoryActions.reveal(quickpick.activeItems[0].item.path, context.associatedView, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1453,7 +1460,7 @@ export async function* pickRepositoriesStep<
), ),
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Repo.reveal(item.path, context.associatedView, {
void RepositoryActions.reveal(item.path, context.associatedView, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1464,7 +1471,7 @@ export async function* pickRepositoriesStep<
onDidPressKey: quickpick => { onDidPressKey: quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
void GitActions.Repo.reveal(quickpick.activeItems[0].item.path, context.associatedView, {
void RepositoryActions.reveal(quickpick.activeItems[0].item.path, context.associatedView, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1520,14 +1527,14 @@ export function* pickStashStep<
], ],
onDidClickItemButton: (_quickpick, button, { item }) => { onDidClickItemButton: (_quickpick, button, { item }) => {
if (button === QuickCommandButtons.ShowDetailsView) { if (button === QuickCommandButtons.ShowDetailsView) {
void GitActions.Stash.showDetailsView(item, { pin: false, preserveFocus: true });
void StashActions.showDetailsView(item, { pin: false, preserveFocus: true });
} }
}, },
keys: ['right', 'alt+right', 'ctrl+right'], keys: ['right', 'alt+right', 'ctrl+right'],
onDidPressKey: async quickpick => { onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
await GitActions.Stash.showDetailsView(quickpick.activeItems[0].item, { pin: false, preserveFocus: true });
await StashActions.showDetailsView(quickpick.activeItems[0].item, { pin: false, preserveFocus: true });
}, },
}); });
const selection: StepSelection<typeof step> = yield step; const selection: StepSelection<typeof step> = yield step;
@ -1569,7 +1576,7 @@ export async function* pickTagsStep<
: tags, : tags,
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
void GitActions.Tag.reveal(item, {
void TagActions.reveal(item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1580,7 +1587,7 @@ export async function* pickTagsStep<
onDidPressKey: async quickpick => { onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
await GitActions.Tag.reveal(quickpick.activeItems[0].item, {
await TagActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1629,10 +1636,10 @@ export async function* pickWorktreeStep<
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
switch (button) { switch (button) {
case QuickCommandButtons.OpenInNewWindow: case QuickCommandButtons.OpenInNewWindow:
GitActions.Worktree.open(item, { location: OpenWorkspaceLocation.NewWindow });
WorktreeActions.open(item, { location: OpenWorkspaceLocation.NewWindow });
break; break;
case QuickCommandButtons.RevealInSideBar: case QuickCommandButtons.RevealInSideBar:
void GitActions.Worktree.reveal(item, { select: true, focus: false, expand: true });
void WorktreeActions.reveal(item, { select: true, focus: false, expand: true });
break; break;
} }
}, },
@ -1640,7 +1647,7 @@ export async function* pickWorktreeStep<
onDidPressKey: async quickpick => { onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
await GitActions.Worktree.reveal(quickpick.activeItems[0].item, {
await WorktreeActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1690,10 +1697,10 @@ export async function* pickWorktreesStep<
onDidClickItemButton: (quickpick, button, { item }) => { onDidClickItemButton: (quickpick, button, { item }) => {
switch (button) { switch (button) {
case QuickCommandButtons.OpenInNewWindow: case QuickCommandButtons.OpenInNewWindow:
GitActions.Worktree.open(item, { location: OpenWorkspaceLocation.NewWindow });
WorktreeActions.open(item, { location: OpenWorkspaceLocation.NewWindow });
break; break;
case QuickCommandButtons.RevealInSideBar: case QuickCommandButtons.RevealInSideBar:
void GitActions.Worktree.reveal(item, { select: true, focus: false, expand: true });
void WorktreeActions.reveal(item, { select: true, focus: false, expand: true });
break; break;
} }
}, },
@ -1701,7 +1708,7 @@ export async function* pickWorktreesStep<
onDidPressKey: async quickpick => { onDidPressKey: async quickpick => {
if (quickpick.activeItems.length === 0) return; if (quickpick.activeItems.length === 0) return;
await GitActions.Worktree.reveal(quickpick.activeItems[0].item, {
await WorktreeActions.reveal(quickpick.activeItems[0].item, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -1737,9 +1744,9 @@ export async function* showCommitOrStashStep<
switch (button) { switch (button) {
case QuickCommandButtons.ShowDetailsView: case QuickCommandButtons.ShowDetailsView:
if (GitReference.isStash(state.reference)) { if (GitReference.isStash(state.reference)) {
void GitActions.Stash.showDetailsView(state.reference, { pin: false, preserveFocus: true });
void StashActions.showDetailsView(state.reference, { pin: false, preserveFocus: true });
} else { } else {
void GitActions.Commit.showDetailsView(state.reference, {
void CommitActions.showDetailsView(state.reference, {
pin: false, pin: false,
preserveFocus: true, preserveFocus: true,
}); });
@ -1747,13 +1754,13 @@ export async function* showCommitOrStashStep<
break; break;
case QuickCommandButtons.RevealInSideBar: case QuickCommandButtons.RevealInSideBar:
if (GitReference.isStash(state.reference)) { if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
void StashActions.reveal(state.reference, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
}); });
} else { } else {
void GitActions.Commit.reveal(state.reference, {
void CommitActions.reveal(state.reference, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -2021,20 +2028,23 @@ export function* showCommitOrStashFilesStep<
switch (button) { switch (button) {
case QuickCommandButtons.ShowDetailsView: case QuickCommandButtons.ShowDetailsView:
if (GitReference.isStash(state.reference)) { if (GitReference.isStash(state.reference)) {
void GitActions.Stash.showDetailsView(state.reference, { pin: false, preserveFocus: true });
void StashActions.showDetailsView(state.reference, { pin: false, preserveFocus: true });
} else { } else {
void GitActions.Commit.showDetailsView(state.reference, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(state.reference, {
pin: false,
preserveFocus: true,
});
} }
break; break;
case QuickCommandButtons.RevealInSideBar: case QuickCommandButtons.RevealInSideBar:
if (GitReference.isStash(state.reference)) { if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
void StashActions.reveal(state.reference, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
}); });
} else { } else {
void GitActions.Commit.reveal(state.reference, {
void CommitActions.reveal(state.reference, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
@ -2085,20 +2095,23 @@ export async function* showCommitOrStashFileStep<
switch (button) { switch (button) {
case QuickCommandButtons.ShowDetailsView: case QuickCommandButtons.ShowDetailsView:
if (GitReference.isStash(state.reference)) { if (GitReference.isStash(state.reference)) {
void GitActions.Stash.showDetailsView(state.reference, { pin: false, preserveFocus: true });
void StashActions.showDetailsView(state.reference, { pin: false, preserveFocus: true });
} else { } else {
void GitActions.Commit.showDetailsView(state.reference, { pin: false, preserveFocus: true });
void CommitActions.showDetailsView(state.reference, {
pin: false,
preserveFocus: true,
});
} }
break; break;
case QuickCommandButtons.RevealInSideBar: case QuickCommandButtons.RevealInSideBar:
if (GitReference.isStash(state.reference)) { if (GitReference.isStash(state.reference)) {
void GitActions.Stash.reveal(state.reference, {
void StashActions.reveal(state.reference, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,
}); });
} else { } else {
void GitActions.Commit.reveal(state.reference, {
void CommitActions.reveal(state.reference, {
select: true, select: true,
focus: false, focus: false,
expand: true, expand: true,

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

@ -1,8 +1,8 @@
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { command } from '../system/command'; import { command } from '../system/command';
import { Command } from './base'; import { Command } from './base';
import { executeGitCommand } from './gitCommands.actions';
@command() @command()
export class FetchRepositoriesCommand extends Command { export class FetchRepositoriesCommand extends Command {

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

@ -1,12 +1,12 @@
import { configuration } from '../configuration'; import { configuration } from '../configuration';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import type { SearchQuery } from '../git/search'; import type { SearchQuery } from '../git/search';
import { command } from '../system/command'; import { command } from '../system/command';
import { SearchResultsNode } from '../views/nodes/searchResultsNode'; import { SearchResultsNode } from '../views/nodes/searchResultsNode';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { Command, isCommandContextViewNodeHasRepository } from './base'; import { Command, isCommandContextViewNodeHasRepository } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface SearchCommitsCommandArgs { export interface SearchCommitsCommandArgs {
search?: Partial<SearchQuery>; search?: Partial<SearchQuery>;

+ 3
- 4
src/commands/showCommitsInView.ts View File

@ -1,6 +1,8 @@
import type { TextEditor, Uri } from 'vscode'; import type { TextEditor, Uri } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { showDetailsView } from '../git/actions/commit';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { GitReference } from '../git/models/reference'; import { GitReference } from '../git/models/reference';
import { createSearchQueryForCommits } from '../git/search'; import { createSearchQueryForCommits } from '../git/search';
@ -10,7 +12,6 @@ import { command } from '../system/command';
import { filterMap } from '../system/iterable'; import { filterMap } from '../system/iterable';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base'; import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base';
import { executeGitCommand, GitActions } from './gitCommands.actions';
export interface ShowCommitsInViewCommandArgs { export interface ShowCommitsInViewCommandArgs {
refs?: string[]; refs?: string[];
@ -80,9 +81,7 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand {
} }
if (args.refs.length === 1) { if (args.refs.length === 1) {
return GitActions.Commit.showDetailsView(
GitReference.create(args.refs[0], args.repoPath!, { refType: 'revision' }),
);
return showDetailsView(GitReference.create(args.refs[0], args.repoPath!, { refType: 'revision' }));
} }
return executeGitCommand({ return executeGitCommand({

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

@ -1,12 +1,12 @@
import type { TextEditor, Uri } from 'vscode'; import type { TextEditor, Uri } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { GitReference } from '../git/models/reference'; import { GitReference } from '../git/models/reference';
import { command } from '../system/command'; import { command } from '../system/command';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { ActiveEditorCachedCommand, getCommandUri } from './base'; import { ActiveEditorCachedCommand, getCommandUri } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface ShowQuickBranchHistoryCommandArgs { export interface ShowQuickBranchHistoryCommandArgs {
repoPath?: string; repoPath?: string;

+ 3
- 2
src/commands/showQuickCommit.ts View File

@ -1,6 +1,8 @@
import type { TextEditor, Uri } from 'vscode'; import type { TextEditor, Uri } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { reveal } from '../git/actions/commit';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import type { GitCommit, GitStashCommit } from '../git/models/commit'; import type { GitCommit, GitStashCommit } from '../git/models/commit';
import type { GitLog } from '../git/models/log'; import type { GitLog } from '../git/models/log';
@ -14,7 +16,6 @@ import {
import { command } from '../system/command'; import { command } from '../system/command';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { ActiveEditorCachedCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base'; import { ActiveEditorCachedCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base';
import { executeGitCommand, GitActions } from './gitCommands.actions';
export interface ShowQuickCommitCommandArgs { export interface ShowQuickCommitCommandArgs {
repoPath?: string; repoPath?: string;
@ -138,7 +139,7 @@ export class ShowQuickCommitCommand extends ActiveEditorCachedCommand {
} }
if (args.revealInView) { if (args.revealInView) {
void (await GitActions.Commit.reveal(args.commit, {
void (await reveal(args.commit, {
select: true, select: true,
focus: true, focus: true,
expand: true, expand: true,

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

@ -2,6 +2,7 @@ import type { TextEditor } from 'vscode';
import { Uri } from 'vscode'; import { Uri } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import type { GitCommit, GitStashCommit } from '../git/models/commit'; import type { GitCommit, GitStashCommit } from '../git/models/commit';
import { isCommit } from '../git/models/commit'; import { isCommit } from '../git/models/commit';
@ -16,7 +17,6 @@ import {
import { command } from '../system/command'; import { command } from '../system/command';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { ActiveEditorCachedCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base'; import { ActiveEditorCachedCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface ShowQuickCommitFileCommandArgs { export interface ShowQuickCommitFileCommandArgs {
sha?: string; sha?: string;

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

@ -1,6 +1,7 @@
import type { Range, TextEditor, Uri } from 'vscode'; import type { Range, TextEditor, Uri } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import type { GitBranch } from '../git/models/branch'; import type { GitBranch } from '../git/models/branch';
import type { GitLog } from '../git/models/log'; import type { GitLog } from '../git/models/log';
@ -10,7 +11,6 @@ import type { CommandQuickPickItem } from '../quickpicks/items/common';
import { command } from '../system/command'; import { command } from '../system/command';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { ActiveEditorCachedCommand, getCommandUri } from './base'; import { ActiveEditorCachedCommand, getCommandUri } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface ShowQuickFileHistoryCommandArgs { export interface ShowQuickFileHistoryCommandArgs {
reference?: GitBranch | GitTag | GitReference; reference?: GitBranch | GitTag | GitReference;

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

@ -1,8 +1,8 @@
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { command } from '../system/command'; import { command } from '../system/command';
import { Command } from './base'; import { Command } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface ShowQuickRepoStatusCommandArgs { export interface ShowQuickRepoStatusCommandArgs {
repoPath?: string; repoPath?: string;

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

@ -1,8 +1,8 @@
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { executeGitCommand } from '../git/actions';
import { command } from '../system/command'; import { command } from '../system/command';
import { Command } from './base'; import { Command } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface ShowQuickStashListCommandArgs { export interface ShowQuickStashListCommandArgs {
repoPath?: string; repoPath?: string;

+ 3
- 3
src/commands/stashApply.ts View File

@ -1,12 +1,12 @@
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { apply, pop } from '../git/actions/stash';
import type { GitStashCommit } from '../git/models/commit'; import type { GitStashCommit } from '../git/models/commit';
import type { GitStashReference } from '../git/models/reference'; import type { GitStashReference } from '../git/models/reference';
import type { CommandQuickPickItem } from '../quickpicks/items/common'; import type { CommandQuickPickItem } from '../quickpicks/items/common';
import { command } from '../system/command'; import { command } from '../system/command';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
import { Command, isCommandContextViewNodeHasCommit, isCommandContextViewNodeHasRepository } from './base'; import { Command, isCommandContextViewNodeHasCommit, isCommandContextViewNodeHasRepository } from './base';
import { GitActions } from './gitCommands.actions';
export interface StashApplyCommandArgs { export interface StashApplyCommandArgs {
deleteAfter?: boolean; deleteAfter?: boolean;
@ -37,9 +37,9 @@ export class StashApplyCommand extends Command {
async execute(args?: StashApplyCommandArgs) { async execute(args?: StashApplyCommandArgs) {
if (args?.deleteAfter) { if (args?.deleteAfter) {
return GitActions.Stash.pop(args?.repoPath ?? args?.stashItem?.repoPath, args?.stashItem);
return pop(args?.repoPath ?? args?.stashItem?.repoPath, args?.stashItem);
} }
return GitActions.Stash.apply(args?.repoPath ?? args?.stashItem?.repoPath, args?.stashItem);
return apply(args?.repoPath ?? args?.stashItem?.repoPath, args?.stashItem);
} }
} }

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

@ -3,6 +3,7 @@ import type { ScmResource } from '../@types/vscode.git.resources';
import { ScmResourceGroupType } from '../@types/vscode.git.resources.enums'; import { ScmResourceGroupType } from '../@types/vscode.git.resources.enums';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { push } from '../git/actions/stash';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import { command } from '../system/command'; import { command } from '../system/command';
import type { CommandContext } from './base'; import type { CommandContext } from './base';
@ -12,7 +13,6 @@ import {
isCommandContextViewNodeHasRepoPath, isCommandContextViewNodeHasRepoPath,
isCommandContextViewNodeHasRepository, isCommandContextViewNodeHasRepository,
} from './base'; } from './base';
import { GitActions } from './gitCommands.actions';
export interface StashSaveCommandArgs { export interface StashSaveCommandArgs {
message?: string; message?: string;
@ -73,6 +73,6 @@ export class StashSaveCommand extends Command {
} }
execute(args?: StashSaveCommandArgs) { execute(args?: StashSaveCommandArgs) {
return GitActions.Stash.push(args?.repoPath, args?.uris, args?.message, args?.keepStaged);
return push(args?.repoPath, args?.uris, args?.message, args?.keepStaged);
} }
} }

+ 26
- 0
src/git/actions.ts View File

@ -0,0 +1,26 @@
import type { Uri } from 'vscode';
import type {
BrowseRepoAtRevisionCommandArgs,
GitCommandsCommandArgs,
GitCommandsCommandArgsWithCompletion,
} from '../commands';
import { Commands } from '../constants';
import { executeCommand, executeEditorCommand } from '../system/command';
import { defer } from '../system/promise';
export async function executeGitCommand(args: GitCommandsCommandArgs): Promise<void> {
const deferred = defer<void>();
void (await executeCommand<GitCommandsCommandArgsWithCompletion>(Commands.GitCommands, {
...args,
completion: deferred,
}));
return deferred.promise;
}
export async function browseAtRevision(uri: Uri, options?: { before?: boolean; openInNewWindow?: boolean }) {
void (await executeEditorCommand<BrowseRepoAtRevisionCommandArgs>(Commands.BrowseRepoAtRevision, undefined, {
uri: uri,
before: options?.before,
openInNewWindow: options?.openInNewWindow,
}));
}

+ 58
- 0
src/git/actions/branch.ts View File

@ -0,0 +1,58 @@
import { Container } from '../../container';
import { executeGitCommand } from '../actions';
import type { GitBranchReference, GitReference } from '../models/reference';
import type { Repository } from '../models/repository';
export function create(repo?: string | Repository, ref?: GitReference, name?: string) {
return executeGitCommand({
command: 'branch',
state: {
subcommand: 'create',
repo: repo,
reference: ref,
name: name,
},
});
}
export function remove(repo?: string | Repository, refs?: GitBranchReference | GitBranchReference[]) {
return executeGitCommand({
command: 'branch',
state: {
subcommand: 'delete',
repo: repo,
references: refs,
},
});
}
export function rename(repo?: string | Repository, ref?: GitBranchReference, name?: string) {
return executeGitCommand({
command: 'branch',
state: {
subcommand: 'rename',
repo: repo,
reference: ref,
name: name,
},
});
}
export async function reveal(
branch: GitBranchReference,
options?: {
select?: boolean;
focus?: boolean;
expand?: boolean | number;
},
) {
const view = branch.remote ? Container.instance.remotesView : Container.instance.branchesView;
const node = view.canReveal
? await view.revealBranch(branch, options)
: await Container.instance.repositoriesView.revealBranch(branch, options);
if (node == null) {
void view.show({ preserveFocus: !options?.focus });
}
return node;
}

+ 600
- 0
src/git/actions/commit.ts View File

@ -0,0 +1,600 @@
import type { TextDocumentShowOptions } from 'vscode';
import { env, Range, Uri, window } from 'vscode';
import type {
DiffWithCommandArgs,
DiffWithPreviousCommandArgs,
DiffWithWorkingCommandArgs,
OpenFileOnRemoteCommandArgs,
OpenWorkingFileCommandArgs,
ShowQuickCommitCommandArgs,
ShowQuickCommitFileCommandArgs,
} from '../../commands';
import type { FileAnnotationType } from '../../config';
import { Commands } from '../../constants';
import { Container } from '../../container';
import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/graphWebview';
import { executeCommand, executeEditorCommand } from '../../system/command';
import { findOrOpenEditor, findOrOpenEditors } from '../../system/utils';
import { GitUri } from '../gitUri';
import type { GitCommit } from '../models/commit';
import { isCommit } from '../models/commit';
import type { GitFile } from '../models/file';
import type { GitRevisionReference } from '../models/reference';
import { GitReference, GitRevision } from '../models/reference';
export async function applyChanges(file: string | GitFile, ref1: GitRevisionReference, ref2?: GitRevisionReference) {
// Open the working file to ensure undo will work
await openFile(file, ref1, { preserveFocus: true, preview: false });
let ref = ref1.ref;
// If the file is `?` (untracked), then this must be a stash, so get the ^3 commit to access the untracked file
if (typeof file !== 'string' && file.status === '?') {
ref = `${ref}^3`;
}
await Container.instance.git.applyChangesToWorkingFile(GitUri.fromFile(file, ref1.repoPath, ref), ref, ref2?.ref);
}
export async function copyIdToClipboard(ref: { repoPath: string; ref: string } | GitCommit) {
await env.clipboard.writeText(ref.ref);
}
export async function copyMessageToClipboard(ref: { repoPath: string; ref: string } | GitCommit): Promise<void> {
let commit;
if (isCommit(ref)) {
commit = ref;
if (commit.message == null) {
await commit.ensureFullDetails();
}
} else {
commit = await Container.instance.git.getCommit(ref.repoPath, ref.ref);
if (commit == null) return;
}
const message = commit.message ?? commit.summary;
await env.clipboard.writeText(message);
}
export async function openAllChanges(commit: GitCommit, options?: TextDocumentShowOptions): Promise<void>;
export async function openAllChanges(
files: GitFile[],
refs: { repoPath: string; ref1: string; ref2: string },
options?: TextDocumentShowOptions,
): Promise<void>;
export async function openAllChanges(
commitOrFiles: GitCommit | GitFile[],
refsOrOptions: { repoPath: string; ref1: string; ref2: string } | TextDocumentShowOptions | undefined,
options?: TextDocumentShowOptions,
) {
let files;
let refs;
if (isCommit(commitOrFiles)) {
if (commitOrFiles.files == null) {
await commitOrFiles.ensureFullDetails();
}
files = commitOrFiles.files ?? [];
refs = {
repoPath: commitOrFiles.repoPath,
// Don't need to worry about verifying the previous sha, as the DiffWith command will
ref1: commitOrFiles.unresolvedPreviousSha,
ref2: commitOrFiles.sha,
};
options = refsOrOptions as TextDocumentShowOptions | undefined;
} else {
files = commitOrFiles;
refs = refsOrOptions as { repoPath: string; ref1: string; ref2: string };
}
if (files.length > 10) {
const result = await window.showWarningMessage(
`Are you sure you want to open the changes for all ${files.length} files?`,
{ title: 'Yes' },
{ title: 'No', isCloseAffordance: true },
);
if (result == null || result.title === 'No') return;
}
options = { preserveFocus: true, preview: false, ...options };
for (const file of files) {
await openChanges(file, refs, options);
}
}
export async function openAllChangesWithDiffTool(commit: GitCommit): Promise<void>;
export async function openAllChangesWithDiffTool(
files: GitFile[],
ref: { repoPath: string; ref: string },
): Promise<void>;
export async function openAllChangesWithDiffTool(
commitOrFiles: GitCommit | GitFile[],
ref?: { repoPath: string; ref: string },
) {
let files;
if (isCommit(commitOrFiles)) {
if (commitOrFiles.files == null) {
await commitOrFiles.ensureFullDetails();
}
files = commitOrFiles.files ?? [];
ref = {
repoPath: commitOrFiles.repoPath,
ref: commitOrFiles.sha,
};
} else {
files = commitOrFiles;
}
if (files.length > 10) {
const result = await window.showWarningMessage(
`Are you sure you want to open the changes for all ${files.length} files?`,
{ title: 'Yes' },
{ title: 'No', isCloseAffordance: true },
);
if (result == null || result.title === 'No') return;
}
for (const file of files) {
void openChangesWithDiffTool(file, ref!);
}
}
export async function openAllChangesWithWorking(commit: GitCommit, options?: TextDocumentShowOptions): Promise<void>;
export async function openAllChangesWithWorking(
files: GitFile[],
ref: { repoPath: string; ref: string },
options?: TextDocumentShowOptions,
): Promise<void>;
export async function openAllChangesWithWorking(
commitOrFiles: GitCommit | GitFile[],
refOrOptions: { repoPath: string; ref: string } | TextDocumentShowOptions | undefined,
options?: TextDocumentShowOptions,
) {
let files;
let ref;
if (isCommit(commitOrFiles)) {
if (commitOrFiles.files == null) {
await commitOrFiles.ensureFullDetails();
}
files = commitOrFiles.files ?? [];
ref = {
repoPath: commitOrFiles.repoPath,
ref: commitOrFiles.sha,
};
options = refOrOptions as TextDocumentShowOptions | undefined;
} else {
files = commitOrFiles;
ref = refOrOptions as { repoPath: string; ref: string };
}
if (files.length > 10) {
const result = await window.showWarningMessage(
`Are you sure you want to open the changes for all ${files.length} files?`,
{ title: 'Yes' },
{ title: 'No', isCloseAffordance: true },
);
if (result == null || result.title === 'No') return;
}
options = { preserveFocus: true, preview: false, ...options };
for (const file of files) {
await openChangesWithWorking(file, ref, options);
}
}
export async function openChanges(
file: string | GitFile,
commit: GitCommit,
options?: TextDocumentShowOptions,
): Promise<void>;
export async function openChanges(
file: GitFile,
refs: { repoPath: string; ref1: string; ref2: string },
options?: TextDocumentShowOptions,
): Promise<void>;
export async function openChanges(
file: string | GitFile,
commitOrRefs: GitCommit | { repoPath: string; ref1: string; ref2: string },
options?: TextDocumentShowOptions,
) {
if (typeof file === 'string') {
if (!isCommit(commitOrRefs)) throw new Error('Invalid arguments');
const f = await commitOrRefs.findFile(file);
if (f == null) throw new Error('Invalid arguments');
file = f;
}
options = { preserveFocus: true, preview: false, ...options };
if (file.status === 'A') {
if (!isCommit(commitOrRefs)) return;
const commit = await commitOrRefs.getCommitForFile(file);
void executeCommand<DiffWithPreviousCommandArgs>(Commands.DiffWithPrevious, {
commit: commit,
showOptions: options,
});
}
const refs = isCommit(commitOrRefs)
? {
repoPath: commitOrRefs.repoPath,
// Don't need to worry about verifying the previous sha, as the DiffWith command will
ref1: commitOrRefs.unresolvedPreviousSha,
ref2: commitOrRefs.sha,
}
: commitOrRefs;
const uri1 = GitUri.fromFile(file, refs.repoPath);
const uri2 =
file.status === 'R' || file.status === 'C' ? GitUri.fromFile(file, refs.repoPath, refs.ref2, true) : uri1;
void (await executeCommand<DiffWithCommandArgs>(Commands.DiffWith, {
repoPath: refs.repoPath,
lhs: { uri: uri1, sha: refs.ref1 },
rhs: { uri: uri2, sha: refs.ref2 },
showOptions: options,
}));
}
export function openChangesWithDiffTool(file: string | GitFile, commit: GitCommit, tool?: string): Promise<void>;
export function openChangesWithDiffTool(
file: GitFile,
ref: { repoPath: string; ref: string },
tool?: string,
): Promise<void>;
export async function openChangesWithDiffTool(
file: string | GitFile,
commitOrRef: GitCommit | { repoPath: string; ref: string },
tool?: string,
) {
if (typeof file === 'string') {
if (!isCommit(commitOrRef)) throw new Error('Invalid arguments');
const f = await commitOrRef.findFile(file);
if (f == null) throw new Error('Invalid arguments');
file = f;
}
return Container.instance.git.openDiffTool(
commitOrRef.repoPath,
GitUri.fromFile(file, file.repoPath ?? commitOrRef.repoPath),
{
ref1: GitRevision.isUncommitted(commitOrRef.ref) ? '' : `${commitOrRef.ref}^`,
ref2: GitRevision.isUncommitted(commitOrRef.ref) ? '' : commitOrRef.ref,
staged: GitRevision.isUncommittedStaged(commitOrRef.ref) || file.indexStatus != null,
tool: tool,
},
);
}
export async function openChangesWithWorking(
file: string | GitFile,
commit: GitCommit,
options?: TextDocumentShowOptions,
): Promise<void>;
export async function openChangesWithWorking(
file: GitFile,
ref: { repoPath: string; ref: string },
options?: TextDocumentShowOptions,
): Promise<void>;
export async function openChangesWithWorking(
file: string | GitFile,
commitOrRef: GitCommit | { repoPath: string; ref: string },
options?: TextDocumentShowOptions,
) {
if (typeof file === 'string') {
if (!isCommit(commitOrRef)) throw new Error('Invalid arguments');
const f = await commitOrRef.findFile(file);
if (f == null) throw new Error('Invalid arguments');
file = f;
}
if (file.status === 'D') return;
let ref;
if (isCommit(commitOrRef)) {
ref = {
repoPath: commitOrRef.repoPath,
ref: commitOrRef.sha,
};
} else {
ref = commitOrRef;
}
options = { preserveFocus: true, preview: false, ...options };
void (await executeEditorCommand<DiffWithWorkingCommandArgs>(Commands.DiffWithWorking, undefined, {
uri: GitUri.fromFile(file, ref.repoPath, ref.ref),
showOptions: options,
}));
}
export async function openDirectoryCompare(
repoPath: string,
ref: string,
ref2: string | undefined,
tool?: string,
): Promise<void> {
return Container.instance.git.openDirectoryCompare(repoPath, ref, ref2, tool);
}
export async function openDirectoryCompareWithPrevious(
ref: { repoPath: string; ref: string } | GitCommit,
): Promise<void> {
return openDirectoryCompare(ref.repoPath, ref.ref, `${ref.ref}^`);
}
export async function openDirectoryCompareWithWorking(
ref: { repoPath: string; ref: string } | GitCommit,
): Promise<void> {
return openDirectoryCompare(ref.repoPath, ref.ref, undefined);
}
export async function openFile(uri: Uri, options?: TextDocumentShowOptions): Promise<void>;
export async function openFile(
file: string | GitFile,
ref: GitRevisionReference,
options?: TextDocumentShowOptions,
): Promise<void>;
export async function openFile(
fileOrUri: string | GitFile | Uri,
refOrOptions?: GitRevisionReference | TextDocumentShowOptions,
options?: TextDocumentShowOptions,
) {
let uri;
if (fileOrUri instanceof Uri) {
uri = fileOrUri;
options = refOrOptions as TextDocumentShowOptions;
} else {
const ref = refOrOptions as GitRevisionReference;
uri = GitUri.fromFile(fileOrUri, ref.repoPath, ref.ref);
// If the file is `?` (untracked), then this must be an untracked file in a stash, so just return
if (typeof fileOrUri !== 'string' && fileOrUri.status === '?') return;
}
options = { preserveFocus: true, preview: false, ...options };
void (await executeEditorCommand<OpenWorkingFileCommandArgs>(Commands.OpenWorkingFile, undefined, {
uri: uri,
showOptions: options,
}));
}
export async function openFileAtRevision(
revisionUri: Uri,
options?: TextDocumentShowOptions & { annotationType?: FileAnnotationType; line?: number },
): Promise<void>;
export async function openFileAtRevision(
file: string | GitFile,
commit: GitCommit,
options?: TextDocumentShowOptions & { annotationType?: FileAnnotationType; line?: number },
): Promise<void>;
export async function openFileAtRevision(
fileOrRevisionUri: string | GitFile | Uri,
commitOrOptions?: GitCommit | TextDocumentShowOptions,
options?: TextDocumentShowOptions & { annotationType?: FileAnnotationType; line?: number },
): Promise<void> {
let uri;
if (fileOrRevisionUri instanceof Uri) {
if (isCommit(commitOrOptions)) throw new Error('Invalid arguments');
uri = fileOrRevisionUri;
options = commitOrOptions;
} else {
if (!isCommit(commitOrOptions)) throw new Error('Invalid arguments');
const commit = commitOrOptions;
let file;
if (typeof fileOrRevisionUri === 'string') {
const f = await commit.findFile(fileOrRevisionUri);
if (f == null) throw new Error('Invalid arguments');
file = f;
} else {
file = fileOrRevisionUri;
}
uri = Container.instance.git.getRevisionUri(
file.status === 'D' ? (await commit.getPreviousSha()) ?? GitRevision.deletedOrMissing : commit.sha,
file,
commit.repoPath,
);
}
const { annotationType, line, ...opts }: Exclude<typeof options, undefined> = {
preserveFocus: true,
preview: false,
...options,
};
if (line != null && line !== 0) {
opts.selection = new Range(line, 0, line, 0);
}
const editor = await findOrOpenEditor(uri, opts);
if (annotationType != null && editor != null) {
void (await Container.instance.fileAnnotations.show(editor, annotationType, {
selection: { line: line },
}));
}
}
export async function openFileOnRemote(uri: Uri): Promise<void>;
export async function openFileOnRemote(file: string | GitFile, ref: GitRevisionReference): Promise<void>;
export async function openFileOnRemote(fileOrUri: string | GitFile | Uri, ref?: GitRevisionReference): Promise<void> {
let uri;
if (fileOrUri instanceof Uri) {
uri = fileOrUri;
} else {
if (ref == null) throw new Error('Invalid arguments');
uri = GitUri.fromFile(fileOrUri, ref.repoPath, ref.ref);
// If the file is `?` (untracked), then this must be an untracked file in a stash, so just return
if (typeof fileOrUri !== 'string' && fileOrUri.status === '?') return;
}
void (await executeCommand<[Uri, OpenFileOnRemoteCommandArgs]>(Commands.OpenFileOnRemote, uri, {
sha: ref?.ref,
}));
}
export async function openFiles(commit: GitCommit): Promise<void>;
export async function openFiles(files: GitFile[], repoPath: string, ref: string): Promise<void>;
export async function openFiles(commitOrFiles: GitCommit | GitFile[], repoPath?: string, ref?: string): Promise<void> {
let files;
if (isCommit(commitOrFiles)) {
if (commitOrFiles.files == null) {
await commitOrFiles.ensureFullDetails();
}
files = commitOrFiles.files ?? [];
repoPath = commitOrFiles.repoPath;
ref = commitOrFiles.sha;
} else {
files = commitOrFiles;
}
if (files.length > 10) {
const result = await window.showWarningMessage(
`Are you sure you want to open all ${files.length} files?`,
{ title: 'Yes' },
{ title: 'No', isCloseAffordance: true },
);
if (result == null || result.title === 'No') return;
}
const uris: Uri[] = (
await Promise.all(
files.map(file => Container.instance.git.getWorkingUri(repoPath!, GitUri.fromFile(file, repoPath!, ref))),
)
).filter(<T>(u?: T): u is T => Boolean(u));
findOrOpenEditors(uris);
}
export async function openFilesAtRevision(commit: GitCommit): Promise<void>;
export async function openFilesAtRevision(
files: GitFile[],
repoPath: string,
ref1: string,
ref2: string,
): Promise<void>;
export async function openFilesAtRevision(
commitOrFiles: GitCommit | GitFile[],
repoPath?: string,
ref1?: string,
ref2?: string,
): Promise<void> {
let files;
if (isCommit(commitOrFiles)) {
if (commitOrFiles.files == null) {
await commitOrFiles.ensureFullDetails();
}
files = commitOrFiles.files ?? [];
repoPath = commitOrFiles.repoPath;
ref1 = commitOrFiles.sha;
ref2 = await commitOrFiles.getPreviousSha();
} else {
files = commitOrFiles;
}
if (files.length > 10) {
const result = await window.showWarningMessage(
`Are you sure you want to open all ${files.length} file revisions?`,
{ title: 'Yes' },
{ title: 'No', isCloseAffordance: true },
);
if (result == null || result.title === 'No') return;
}
findOrOpenEditors(
files.map(file => Container.instance.git.getRevisionUri(file.status === 'D' ? ref2! : ref1!, file, repoPath!)),
);
}
export async function restoreFile(file: string | GitFile, revision: GitRevisionReference) {
let path;
let ref;
if (typeof file === 'string') {
path = file;
ref = revision.ref;
} else {
path = file.path;
ref = file.status === `?` ? `${revision.ref}^3` : file.status === 'D' ? `${revision.ref}^` : revision.ref;
}
await Container.instance.git.checkout(revision.repoPath, ref, { path: path });
}
export async function reveal(
commit: GitRevisionReference,
options?: {
select?: boolean;
focus?: boolean;
expand?: boolean | number;
},
) {
const views = [Container.instance.commitsView, Container.instance.branchesView, Container.instance.remotesView];
// TODO@eamodio stop duplicate notifications
for (const view of views) {
const node = view.canReveal
? await view.revealCommit(commit, options)
: await Container.instance.repositoriesView.revealCommit(commit, options);
if (node != null) return node;
}
void views[0].show({ preserveFocus: !options?.focus });
return undefined;
}
export async function showDetailsQuickPick(commit: GitCommit, uri?: Uri): Promise<void>;
export async function showDetailsQuickPick(commit: GitCommit, file?: string | GitFile): Promise<void>;
export async function showDetailsQuickPick(commit: GitCommit, fileOrUri?: string | GitFile | Uri): Promise<void> {
if (fileOrUri == null) {
void (await executeCommand<ShowQuickCommitCommandArgs>(Commands.ShowQuickCommit, { commit: commit }));
return;
}
let uri;
if (fileOrUri instanceof Uri) {
uri = fileOrUri;
} else {
uri = GitUri.fromFile(fileOrUri, commit.repoPath, commit.ref);
}
void (await executeCommand<[Uri, ShowQuickCommitFileCommandArgs]>(Commands.ShowQuickCommitFile, uri, {
sha: commit.sha,
}));
}
export function showDetailsView(
commit: GitRevisionReference | GitCommit,
options?: { pin?: boolean; preserveFocus?: boolean; preserveVisibility?: boolean },
): Promise<void> {
return Container.instance.commitDetailsView.show({ ...options, commit: commit });
}
export async function showInCommitGraph(
commit: GitRevisionReference | GitCommit,
options?: { preserveFocus?: boolean },
): Promise<void> {
void (await executeCommand<ShowInCommitGraphCommandArgs>(Commands.ShowInCommitGraph, {
ref: GitReference.fromRevision(commit),
preserveFocus: options?.preserveFocus,
}));
}

+ 29
- 0
src/git/actions/contributor.ts View File

@ -0,0 +1,29 @@
import { Container } from '../../container';
import { executeGitCommand } from '../actions';
import type { GitContributor } from '../models/contributor';
import type { Repository } from '../models/repository';
export function addAuthors(repo?: string | Repository, contributors?: GitContributor | GitContributor[]) {
return executeGitCommand({
command: 'co-authors',
state: { repo: repo, contributors: contributors },
});
}
export async function reveal(
contributor: GitContributor,
options?: {
select?: boolean;
focus?: boolean;
expand?: boolean | number;
},
) {
const view = Container.instance.contributorsView;
const node = view.canReveal
? await view.revealContributor(contributor, options)
: await Container.instance.repositoriesView.revealContributor(contributor, options);
if (node == null) {
void view.show({ preserveFocus: !options?.focus });
}
return node;
}

+ 70
- 0
src/git/actions/remote.ts View File

@ -0,0 +1,70 @@
import { Container } from '../../container';
import { executeGitCommand } from '../actions';
import type { GitRemote } from '../models/remote';
import type { Repository } from '../models/repository';
export function add(
repo?: string | Repository,
name?: string,
url?: string,
options?: { confirm?: boolean; fetch?: boolean; reveal?: boolean },
) {
return executeGitCommand({
command: 'remote',
confirm: options?.confirm,
state: {
repo: repo,
subcommand: 'add',
name: name,
url: url,
flags: options?.fetch ? ['-f'] : undefined,
reveal: options?.reveal,
},
});
}
export async function fetch(repo: string | Repository, remote: string) {
if (typeof repo === 'string') {
const r = Container.instance.git.getRepository(repo);
if (r == null) return;
repo = r;
}
await repo.fetch({ remote: remote });
}
export async function prune(repo: string | Repository, remote: string) {
return executeGitCommand({
command: 'remote',
state: { repo: repo, subcommand: 'prune', remote: remote },
});
}
export async function remove(repo: string | Repository, remote: string) {
return executeGitCommand({
command: 'remote',
state: { repo: repo, subcommand: 'remove', remote: remote },
});
}
export async function reveal(
remote: GitRemote | undefined,
options?: {
select?: boolean;
focus?: boolean;
expand?: boolean | number;
},
) {
const view = Container.instance.remotesView;
const node =
remote != null
? view.canReveal
? await view.revealRemote(remote, options)
: await Container.instance.repositoriesView.revealRemote(remote, options)
: undefined;
if (node == null) {
void view.show({ preserveFocus: !options?.focus });
}
return node;
}

+ 84
- 0
src/git/actions/repository.ts View File

@ -0,0 +1,84 @@
import type { ResetGitCommandArgs } from '../../commands/git/reset';
import { Container } from '../../container';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { executeGitCommand } from '../actions';
import type { GitBranchReference, GitReference, GitRevisionReference } from '../models/reference';
import type { Repository } from '../models/repository';
export function cherryPick(repo?: string | Repository, refs?: GitRevisionReference | GitRevisionReference[]) {
return executeGitCommand({
command: 'cherry-pick',
state: { repo: repo, references: refs },
});
}
export function fetch(repos?: string | string[] | Repository | Repository[], ref?: GitBranchReference) {
return executeGitCommand({ command: 'fetch', state: { repos: repos, reference: ref } });
}
export function merge(repo?: string | Repository, ref?: GitReference) {
return executeGitCommand({ command: 'merge', state: { repo: repo, reference: ref } });
}
export function pull(repos?: string | string[] | Repository | Repository[], ref?: GitBranchReference) {
return executeGitCommand({ command: 'pull', state: { repos: repos, reference: ref } });
}
export function push(repos?: string | string[] | Repository | Repository[], force?: boolean, ref?: GitReference) {
return executeGitCommand({
command: 'push',
state: { repos: repos, flags: force ? ['--force'] : [], reference: ref },
});
}
export function rebase(repo?: string | Repository, ref?: GitReference, interactive: boolean = true) {
return executeGitCommand({
command: 'rebase',
state: { repo: repo, reference: ref, flags: interactive ? ['--interactive'] : [] },
});
}
export function reset(
repo?: string | Repository,
ref?: GitRevisionReference,
flags?: NonNullable<ResetGitCommandArgs['state']>['flags'],
) {
return executeGitCommand({
command: 'reset',
confirm: flags == null || flags.includes('--hard'),
state: { repo: repo, reference: ref, flags: flags },
});
}
export function revert(repo?: string | Repository, refs?: GitRevisionReference | GitRevisionReference[]) {
return executeGitCommand({
command: 'revert',
state: { repo: repo, references: refs },
});
}
export function switchTo(repos?: string | string[] | Repository | Repository[], ref?: GitReference, confirm?: boolean) {
return executeGitCommand({
command: 'switch',
state: { repos: repos, reference: ref },
confirm: confirm,
});
}
export async function reveal(
repoPath: string,
view?: ViewsWithRepositoryFolders,
options?: {
select?: boolean;
focus?: boolean;
expand?: boolean | number;
},
) {
const node = view?.canReveal
? await view.revealRepository(repoPath, options)
: await Container.instance.repositoriesView.revealRepository(repoPath, options);
if (node == null) {
void (view ?? Container.instance.repositoriesView).show({ preserveFocus: !options?.focus });
}
return node;
}

+ 65
- 0
src/git/actions/stash.ts View File

@ -0,0 +1,65 @@
import type { Uri } from 'vscode';
import { Container } from '../../container';
import { executeGitCommand } from '../actions';
import type { GitStashCommit } from '../models/commit';
import type { GitStashReference } from '../models/reference';
import type { Repository } from '../models/repository';
export function apply(repo?: string | Repository, ref?: GitStashReference) {
return executeGitCommand({
command: 'stash',
state: { subcommand: 'apply', repo: repo, reference: ref },
});
}
export function drop(repo?: string | Repository, ref?: GitStashReference) {
return executeGitCommand({
command: 'stash',
state: { subcommand: 'drop', repo: repo, reference: ref },
});
}
export function pop(repo?: string | Repository, ref?: GitStashReference) {
return executeGitCommand({
command: 'stash',
state: { subcommand: 'pop', repo: repo, reference: ref },
});
}
export function push(repo?: string | Repository, uris?: Uri[], message?: string, keepStaged: boolean = false) {
return executeGitCommand({
command: 'stash',
state: {
subcommand: 'push',
repo: repo,
uris: uris,
message: message,
flags: keepStaged ? ['--keep-index'] : undefined,
},
});
}
export async function reveal(
stash: GitStashReference,
options?: {
select?: boolean;
focus?: boolean;
expand?: boolean | number;
},
) {
const view = Container.instance.stashesView;
const node = view.canReveal
? await view.revealStash(stash, options)
: await Container.instance.repositoriesView.revealStash(stash, options);
if (node == null) {
void view.show({ preserveFocus: !options?.focus });
}
return node;
}
export function showDetailsView(
stash: GitStashReference | GitStashCommit,
options?: { pin?: boolean; preserveFocus?: boolean },
): Promise<void> {
return Container.instance.commitDetailsView.show({ ...options, commit: stash });
}

+ 45
- 0
src/git/actions/tag.ts View File

@ -0,0 +1,45 @@
import { Container } from '../../container';
import { executeGitCommand } from '../actions';
import type { GitReference, GitTagReference } from '../models/reference';
import type { Repository } from '../models/repository';
export function create(repo?: string | Repository, ref?: GitReference, name?: string) {
return executeGitCommand({
command: 'tag',
state: {
subcommand: 'create',
repo: repo,
reference: ref,
name: name,
},
});
}
export function remove(repo?: string | Repository, refs?: GitTagReference | GitTagReference[]) {
return executeGitCommand({
command: 'tag',
state: {
subcommand: 'delete',
repo: repo,
references: refs,
},
});
}
export async function reveal(
tag: GitTagReference,
options?: {
select?: boolean;
focus?: boolean;
expand?: boolean | number;
},
) {
const view = Container.instance.tagsView;
const node = view.canReveal
? await view.revealTag(tag, options)
: await Container.instance.repositoriesView.revealTag(tag, options);
if (node == null) {
void view.show({ preserveFocus: !options?.focus });
}
return node;
}

+ 50
- 0
src/git/actions/worktree.ts View File

@ -0,0 +1,50 @@
import type { Uri } from 'vscode';
import { CoreCommands } from '../../constants';
import { Container } from '../../container';
import { ensure } from '../../system/array';
import { executeCoreCommand } from '../../system/command';
import type { OpenWorkspaceLocation} from '../../system/utils';
import { openWorkspace } from '../../system/utils';
import { executeGitCommand } from '../actions';
import type { GitReference } from '../models/reference';
import type { Repository } from '../models/repository';
import type { GitWorktree } from '../models/worktree';
export function create(repo?: string | Repository, uri?: Uri, ref?: GitReference, options?: { reveal?: boolean }) {
return executeGitCommand({
command: 'worktree',
state: { subcommand: 'create', repo: repo, uri: uri, reference: ref, reveal: options?.reveal },
});
}
export function open(worktree: GitWorktree, options?: { location?: OpenWorkspaceLocation }) {
return openWorkspace(worktree.uri, options);
}
export function remove(repo?: string | Repository, uri?: Uri) {
return executeGitCommand({
command: 'worktree',
state: { subcommand: 'delete', repo: repo, uris: ensure(uri) },
});
}
export async function reveal(
worktree: GitWorktree | undefined,
options?: { select?: boolean; focus?: boolean; expand?: boolean | number },
) {
const view = Container.instance.worktreesView;
const node =
worktree != null
? view.canReveal
? await view.revealWorktree(worktree, options)
: await Container.instance.repositoriesView.revealWorktree(worktree, options)
: undefined;
if (node == null) {
void view.show({ preserveFocus: !options?.focus });
}
return node;
}
export async function revealInFileExplorer(worktree: GitWorktree) {
void (await executeCoreCommand(CoreCommands.RevealInFileExplorer, worktree.uri));
}

+ 31
- 26
src/plus/webviews/graph/graphWebview.ts View File

@ -27,13 +27,18 @@ import type {
ShowCommitsInViewCommandArgs, ShowCommitsInViewCommandArgs,
} from '../../../commands'; } from '../../../commands';
import { parseCommandContext } from '../../../commands/base'; import { parseCommandContext } from '../../../commands/base';
import { GitActions } from '../../../commands/gitCommands.actions';
import type { Config } from '../../../configuration'; import type { Config } from '../../../configuration';
import { configuration } from '../../../configuration'; import { configuration } from '../../../configuration';
import { Commands, ContextKeys, CoreCommands, CoreGitCommands, GlyphChars } from '../../../constants'; import { Commands, ContextKeys, CoreCommands, CoreGitCommands, GlyphChars } from '../../../constants';
import type { Container } from '../../../container'; import type { Container } from '../../../container';
import { getContext, onDidChangeContext } from '../../../context'; import { getContext, onDidChangeContext } from '../../../context';
import { PlusFeatures } from '../../../features'; import { PlusFeatures } from '../../../features';
import * as BranchActions from '../../../git/actions/branch';
import * as ContributorActions from '../../../git/actions/contributor';
import * as RepoActions from '../../../git/actions/repository';
import * as StashActions from '../../../git/actions/stash';
import * as TagActions from '../../../git/actions/tag';
import * as WorktreeActions from '../../../git/actions/worktree';
import { GitSearchError } from '../../../git/errors'; import { GitSearchError } from '../../../git/errors';
import { getBranchId, getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../../../git/models/branch'; import { getBranchId, getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../../../git/models/branch';
import { GitContributor } from '../../../git/models/contributor'; import { GitContributor } from '../../../git/models/contributor';
@ -698,11 +703,11 @@ export class GraphWebview extends WebviewBase {
if (isGraphItemRefContext(item)) { if (isGraphItemRefContext(item)) {
const { ref } = item.webviewItemValue; const { ref } = item.webviewItemValue;
if (e.ref.refType === 'head' && e.ref.isCurrentHead) { if (e.ref.refType === 'head' && e.ref.isCurrentHead) {
return GitActions.switchTo(ref.repoPath);
return RepoActions.switchTo(ref.repoPath);
} }
// Override the default confirmation if the setting is unset // Override the default confirmation if the setting is unset
return GitActions.switchTo(
return RepoActions.switchTo(
ref.repoPath, ref.repoPath,
ref, ref,
configuration.isUnset('gitCommands.skipConfirmations') ? true : undefined, configuration.isUnset('gitCommands.skipConfirmations') ? true : undefined,
@ -1926,17 +1931,17 @@ export class GraphWebview extends WebviewBase {
@debug() @debug()
private fetch() { private fetch() {
void GitActions.fetch(this.repository);
void RepoActions.fetch(this.repository);
} }
@debug() @debug()
private pull() { private pull() {
void GitActions.pull(this.repository);
void RepoActions.pull(this.repository);
} }
@debug() @debug()
private push() { private push() {
void GitActions.push(this.repository);
void RepoActions.push(this.repository);
} }
@debug() @debug()
@ -1944,14 +1949,14 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item); const ref = this.getGraphItemRef(item);
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.Branch.create(ref.repoPath, ref);
return BranchActions.create(ref.repoPath, ref);
} }
@debug() @debug()
private deleteBranch(item?: GraphItemContext) { private deleteBranch(item?: GraphItemContext) {
if (isGraphItemRefContext(item, 'branch')) { if (isGraphItemRefContext(item, 'branch')) {
const { ref } = item.webviewItemValue; const { ref } = item.webviewItemValue;
return GitActions.Branch.remove(ref.repoPath, ref);
return BranchActions.remove(ref.repoPath, ref);
} }
return Promise.resolve(); return Promise.resolve();
@ -1961,7 +1966,7 @@ export class GraphWebview extends WebviewBase {
private mergeBranchInto(item?: GraphItemContext) { private mergeBranchInto(item?: GraphItemContext) {
if (isGraphItemRefContext(item, 'branch')) { if (isGraphItemRefContext(item, 'branch')) {
const { ref } = item.webviewItemValue; const { ref } = item.webviewItemValue;
return GitActions.merge(ref.repoPath, ref);
return RepoActions.merge(ref.repoPath, ref);
} }
return Promise.resolve(); return Promise.resolve();
@ -1986,7 +1991,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item); const ref = this.getGraphItemRef(item);
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.rebase(ref.repoPath, ref);
return RepoActions.rebase(ref.repoPath, ref);
} }
@debug() @debug()
@ -1994,7 +1999,7 @@ export class GraphWebview extends WebviewBase {
if (isGraphItemRefContext(item, 'branch')) { if (isGraphItemRefContext(item, 'branch')) {
const { ref } = item.webviewItemValue; const { ref } = item.webviewItemValue;
if (ref.upstream != null) { if (ref.upstream != null) {
return GitActions.rebase(
return RepoActions.rebase(
ref.repoPath, ref.repoPath,
GitReference.create(ref.upstream.name, ref.repoPath, { GitReference.create(ref.upstream.name, ref.repoPath, {
refType: 'branch', refType: 'branch',
@ -2012,7 +2017,7 @@ export class GraphWebview extends WebviewBase {
private renameBranch(item?: GraphItemContext) { private renameBranch(item?: GraphItemContext) {
if (isGraphItemRefContext(item, 'branch')) { if (isGraphItemRefContext(item, 'branch')) {
const { ref } = item.webviewItemValue; const { ref } = item.webviewItemValue;
return GitActions.Branch.rename(ref.repoPath, ref);
return BranchActions.rename(ref.repoPath, ref);
} }
return Promise.resolve(); return Promise.resolve();
@ -2023,7 +2028,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item, 'revision'); const ref = this.getGraphItemRef(item, 'revision');
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.cherryPick(ref.repoPath, ref);
return RepoActions.cherryPick(ref.repoPath, ref);
} }
@debug() @debug()
@ -2106,7 +2111,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item, 'revision'); const ref = this.getGraphItemRef(item, 'revision');
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.reset(
return RepoActions.reset(
ref.repoPath, ref.repoPath,
GitReference.create(`${ref.ref}^`, ref.repoPath, { GitReference.create(`${ref.ref}^`, ref.repoPath, {
refType: 'revision', refType: 'revision',
@ -2121,7 +2126,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item, 'revision'); const ref = this.getGraphItemRef(item, 'revision');
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.reset(ref.repoPath, ref);
return RepoActions.reset(ref.repoPath, ref);
} }
@debug() @debug()
@ -2129,7 +2134,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item, 'revision'); const ref = this.getGraphItemRef(item, 'revision');
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.revert(ref.repoPath, ref);
return RepoActions.revert(ref.repoPath, ref);
} }
@debug() @debug()
@ -2137,7 +2142,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item); const ref = this.getGraphItemRef(item);
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.switchTo(ref.repoPath, ref);
return RepoActions.switchTo(ref.repoPath, ref);
} }
@debug() @debug()
@ -2174,9 +2179,9 @@ export class GraphWebview extends WebviewBase {
@debug() @debug()
private switchToAnother(item?: GraphItemContext | unknown) { private switchToAnother(item?: GraphItemContext | unknown) {
const ref = this.getGraphItemRef(item); const ref = this.getGraphItemRef(item);
if (ref == null) return GitActions.switchTo(this.repository?.path);
if (ref == null) return RepoActions.switchTo(this.repository?.path);
return GitActions.switchTo(ref.repoPath);
return RepoActions.switchTo(ref.repoPath);
} }
@debug() @debug()
@ -2206,7 +2211,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item); const ref = this.getGraphItemRef(item);
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.Stash.push(ref.repoPath);
return StashActions.push(ref.repoPath);
} }
@debug() @debug()
@ -2214,7 +2219,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item, 'stash'); const ref = this.getGraphItemRef(item, 'stash');
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.Stash.apply(ref.repoPath, ref);
return StashActions.apply(ref.repoPath, ref);
} }
@debug() @debug()
@ -2222,7 +2227,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item, 'stash'); const ref = this.getGraphItemRef(item, 'stash');
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.Stash.drop(ref.repoPath, ref);
return StashActions.drop(ref.repoPath, ref);
} }
@debug() @debug()
@ -2230,14 +2235,14 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item); const ref = this.getGraphItemRef(item);
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.Tag.create(ref.repoPath, ref);
return TagActions.create(ref.repoPath, ref);
} }
@debug() @debug()
private deleteTag(item?: GraphItemContext) { private deleteTag(item?: GraphItemContext) {
if (isGraphItemRefContext(item, 'tag')) { if (isGraphItemRefContext(item, 'tag')) {
const { ref } = item.webviewItemValue; const { ref } = item.webviewItemValue;
return GitActions.Tag.remove(ref.repoPath, ref);
return TagActions.remove(ref.repoPath, ref);
} }
return Promise.resolve(); return Promise.resolve();
@ -2248,7 +2253,7 @@ export class GraphWebview extends WebviewBase {
const ref = this.getGraphItemRef(item); const ref = this.getGraphItemRef(item);
if (ref == null) return Promise.resolve(); if (ref == null) return Promise.resolve();
return GitActions.Worktree.create(ref.repoPath, undefined, ref);
return WorktreeActions.create(ref.repoPath, undefined, ref);
} }
@debug() @debug()
@ -2355,7 +2360,7 @@ export class GraphWebview extends WebviewBase {
private addAuthor(item?: GraphItemContext) { private addAuthor(item?: GraphItemContext) {
if (isGraphItemTypedContext(item, 'contributor')) { if (isGraphItemTypedContext(item, 'contributor')) {
const { repoPath, name, email, current } = item.webviewItemValue; const { repoPath, name, email, current } = item.webviewItemValue;
return GitActions.Contributor.addAuthors(
return ContributorActions.addAuthors(
repoPath, repoPath,
new GitContributor(repoPath, name, email, 0, undefined, current), new GitContributor(repoPath, name, email, 0, undefined, current),
); );

+ 2
- 2
src/plus/webviews/timeline/timelineWebview.ts View File

@ -1,11 +1,11 @@
'use strict'; 'use strict';
import type { Disposable, TextEditor, ViewColumn } from 'vscode'; import type { Disposable, TextEditor, ViewColumn } from 'vscode';
import { Uri, window } from 'vscode'; import { Uri, window } from 'vscode';
import { GitActions } from '../../../commands/gitCommands.actions';
import { configuration } from '../../../configuration'; import { configuration } from '../../../configuration';
import { Commands, ContextKeys } from '../../../constants'; import { Commands, ContextKeys } from '../../../constants';
import type { Container } from '../../../container'; import type { Container } from '../../../container';
import { PlusFeatures } from '../../../features'; import { PlusFeatures } from '../../../features';
import { showDetailsView } from '../../../git/actions/commit';
import { GitUri } from '../../../git/gitUri'; import { GitUri } from '../../../git/gitUri';
import { getChangedFilesCount } from '../../../git/models/commit'; import { getChangedFilesCount } from '../../../git/models/commit';
import type { RepositoryChangeEvent } from '../../../git/models/repository'; import type { RepositoryChangeEvent } from '../../../git/models/repository';
@ -139,7 +139,7 @@ export class TimelineWebview extends WebviewBase {
const commit = await repository.getCommit(params.data.id); const commit = await repository.getCommit(params.data.id);
if (commit == null) return; if (commit == null) return;
void GitActions.Commit.showDetailsView(commit, { pin: false, preserveFocus: true });
void showDetailsView(commit, { pin: false, preserveFocus: true });
}); });
break; break;

+ 22
- 21
src/quickpicks/items/commits.ts View File

@ -1,10 +1,11 @@
import type { QuickPickItem } from 'vscode'; import type { QuickPickItem } from 'vscode';
import { window } from 'vscode'; import { window } from 'vscode';
import { GitActions } from '../../commands/gitCommands.actions';
import type { OpenChangedFilesCommandArgs } from '../../commands/openChangedFiles'; import type { OpenChangedFilesCommandArgs } from '../../commands/openChangedFiles';
import { QuickCommandButtons } from '../../commands/quickCommand.buttons'; import { QuickCommandButtons } from '../../commands/quickCommand.buttons';
import { Commands, GlyphChars } from '../../constants'; import { Commands, GlyphChars } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { browseAtRevision } from '../../git/actions';
import * as CommitActions from '../../git/actions/commit';
import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { CommitFormatter } from '../../git/formatters/commitFormatter';
import type { GitCommit } from '../../git/models/commit'; import type { GitCommit } from '../../git/models/commit';
import type { GitFileChange } from '../../git/models/file'; import type { GitFileChange } from '../../git/models/file';
@ -76,7 +77,7 @@ export class CommitFileQuickPickItem extends CommandQuickPickItem {
} }
override execute(options?: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options?: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openChanges(this.file, this.commit, options);
return CommitActions.openChanges(this.file, this.commit, options);
// const fileCommit = await this.commit.getCommitForFile(this.file)!; // const fileCommit = await this.commit.getCommitForFile(this.file)!;
// if (fileCommit.previousSha === undefined) { // if (fileCommit.previousSha === undefined) {
@ -114,7 +115,7 @@ export class CommitBrowseRepositoryFromHereCommandQuickPickItem extends CommandQ
} }
override execute(_options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(_options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.browseAtRevision(this.commit.getGitUri(), {
return browseAtRevision(this.commit.getGitUri(), {
before: this.executeOptions?.before, before: this.executeOptions?.before,
openInNewWindow: this.executeOptions?.openInNewWindow, openInNewWindow: this.executeOptions?.openInNewWindow,
}); });
@ -147,7 +148,7 @@ export class CommitCopyIdQuickPickItem extends CommandQuickPickItem {
} }
override execute(): Promise<void> { override execute(): Promise<void> {
return GitActions.Commit.copyIdToClipboard(this.commit);
return CommitActions.copyIdToClipboard(this.commit);
} }
override async onDidPressKey(key: Keys): Promise<void> { override async onDidPressKey(key: Keys): Promise<void> {
@ -162,7 +163,7 @@ export class CommitCopyMessageQuickPickItem extends CommandQuickPickItem {
} }
override execute(): Promise<void> { override execute(): Promise<void> {
return GitActions.Commit.copyMessageToClipboard(this.commit);
return CommitActions.copyMessageToClipboard(this.commit);
} }
override async onDidPressKey(key: Keys): Promise<void> { override async onDidPressKey(key: Keys): Promise<void> {
@ -179,7 +180,7 @@ export class CommitOpenAllChangesCommandQuickPickItem extends CommandQuickPickIt
} }
override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openAllChanges(this.commit, options);
return CommitActions.openAllChanges(this.commit, options);
} }
} }
@ -189,7 +190,7 @@ export class CommitOpenAllChangesWithDiffToolCommandQuickPickItem extends Comman
} }
override execute(): Promise<void> { override execute(): Promise<void> {
return GitActions.Commit.openAllChangesWithDiffTool(this.commit);
return CommitActions.openAllChangesWithDiffTool(this.commit);
} }
} }
@ -199,7 +200,7 @@ export class CommitOpenAllChangesWithWorkingCommandQuickPickItem extends Command
} }
override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openAllChangesWithWorking(this.commit, options);
return CommitActions.openAllChangesWithWorking(this.commit, options);
} }
} }
@ -209,7 +210,7 @@ export class CommitOpenChangesCommandQuickPickItem extends CommandQuickPickItem
} }
override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openChanges(this.file, this.commit, options);
return CommitActions.openChanges(this.file, this.commit, options);
} }
} }
@ -219,7 +220,7 @@ export class CommitOpenChangesWithDiffToolCommandQuickPickItem extends CommandQu
} }
override execute(): Promise<void> { override execute(): Promise<void> {
return GitActions.Commit.openChangesWithDiffTool(this.file, this.commit);
return CommitActions.openChangesWithDiffTool(this.file, this.commit);
} }
} }
@ -229,7 +230,7 @@ export class CommitOpenChangesWithWorkingCommandQuickPickItem extends CommandQui
} }
override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openChangesWithWorking(this.file, this.commit, options);
return CommitActions.openChangesWithWorking(this.file, this.commit, options);
} }
} }
@ -239,7 +240,7 @@ export class CommitOpenDirectoryCompareCommandQuickPickItem extends CommandQuick
} }
override execute(): Promise<void> { override execute(): Promise<void> {
return GitActions.Commit.openDirectoryCompareWithPrevious(this.commit);
return CommitActions.openDirectoryCompareWithPrevious(this.commit);
} }
} }
@ -249,7 +250,7 @@ export class CommitOpenDirectoryCompareWithWorkingCommandQuickPickItem extends C
} }
override execute(): Promise<void> { override execute(): Promise<void> {
return GitActions.Commit.openDirectoryCompareWithWorking(this.commit);
return CommitActions.openDirectoryCompareWithWorking(this.commit);
} }
} }
@ -259,7 +260,7 @@ export class CommitOpenDetailsCommandQuickPickItem extends CommandQuickPickItem
} }
override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.showDetailsView(this.commit, { preserveFocus: options?.preserveFocus });
return CommitActions.showDetailsView(this.commit, { preserveFocus: options?.preserveFocus });
} }
} }
@ -269,7 +270,7 @@ export class CommitOpenInGraphCommandQuickPickItem extends CommandQuickPickItem
} }
override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.showInCommitGraph(this.commit, { preserveFocus: options?.preserveFocus });
return CommitActions.showInCommitGraph(this.commit, { preserveFocus: options?.preserveFocus });
} }
} }
@ -279,7 +280,7 @@ export class CommitOpenFilesCommandQuickPickItem extends CommandQuickPickItem {
} }
override execute(_options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(_options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openFiles(this.commit);
return CommitActions.openFiles(this.commit);
} }
} }
@ -289,7 +290,7 @@ export class CommitOpenFileCommandQuickPickItem extends CommandQuickPickItem {
} }
override execute(options?: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options?: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openFile(this.file, this.commit, options);
return CommitActions.openFile(this.file, this.commit, options);
} }
} }
@ -299,7 +300,7 @@ export class CommitOpenRevisionsCommandQuickPickItem extends CommandQuickPickIte
} }
override execute(_options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(_options: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openFilesAtRevision(this.commit);
return CommitActions.openFilesAtRevision(this.commit);
} }
} }
@ -309,7 +310,7 @@ export class CommitOpenRevisionCommandQuickPickItem extends CommandQuickPickItem
} }
override execute(options?: { preserveFocus?: boolean; preview?: boolean }): Promise<void> { override execute(options?: { preserveFocus?: boolean; preview?: boolean }): Promise<void> {
return GitActions.Commit.openFileAtRevision(this.file, this.commit, options);
return CommitActions.openFileAtRevision(this.file, this.commit, options);
} }
} }
@ -319,7 +320,7 @@ export class CommitApplyFileChangesCommandQuickPickItem extends CommandQuickPick
} }
override async execute(): Promise<void> { override async execute(): Promise<void> {
return GitActions.Commit.applyChanges(this.file, this.commit);
return CommitActions.applyChanges(this.file, this.commit);
} }
} }
@ -334,7 +335,7 @@ export class CommitRestoreFileChangesCommandQuickPickItem extends CommandQuickPi
} }
override execute(): Promise<void> { override execute(): Promise<void> {
return GitActions.Commit.restoreFile(this.file, this.commit);
return CommitActions.restoreFile(this.file, this.commit);
} }
} }

+ 6
- 4
src/quickpicks/referencePicker.ts View File

@ -1,9 +1,11 @@
import type { Disposable, QuickPick } from 'vscode'; import type { Disposable, QuickPick } from 'vscode';
import { CancellationTokenSource, window } from 'vscode'; import { CancellationTokenSource, window } from 'vscode';
import { GitActions } from '../commands/gitCommands.actions';
import { getBranchesAndOrTags, getValidateGitReferenceFn, QuickCommandButtons } from '../commands/quickCommand'; import { getBranchesAndOrTags, getValidateGitReferenceFn, QuickCommandButtons } from '../commands/quickCommand';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { reveal as revealBranch } from '../git/actions/branch';
import { showDetailsView } from '../git/actions/commit';
import { reveal as revealTag } from '../git/actions/tag';
import type { BranchSortOptions, GitBranch } from '../git/models/branch'; import type { BranchSortOptions, GitBranch } from '../git/models/branch';
import { GitReference } from '../git/models/reference'; import { GitReference } from '../git/models/reference';
import type { GitTag, TagSortOptions } from '../git/models/tag'; import type { GitTag, TagSortOptions } from '../git/models/tag';
@ -133,11 +135,11 @@ export namespace ReferencePicker {
quickpick.onDidTriggerItemButton(({ button, item: { item } }) => { quickpick.onDidTriggerItemButton(({ button, item: { item } }) => {
if (button === QuickCommandButtons.RevealInSideBar) { if (button === QuickCommandButtons.RevealInSideBar) {
if (GitReference.isBranch(item)) { if (GitReference.isBranch(item)) {
void GitActions.Branch.reveal(item, { select: true, expand: true });
void revealBranch(item, { select: true, expand: true });
} else if (GitReference.isTag(item)) { } else if (GitReference.isTag(item)) {
void GitActions.Tag.reveal(item, { select: true, expand: true });
void revealTag(item, { select: true, expand: true });
} else if (GitReference.isRevision(item)) { } else if (GitReference.isRevision(item)) {
void GitActions.Commit.showDetailsView(item, {
void showDetailsView(item, {
pin: false, pin: false,
preserveFocus: true, preserveFocus: true,
}); });

+ 1
- 1
src/views/nodes/searchResultsNode.ts View File

@ -1,6 +1,6 @@
import type { TreeItem } from 'vscode'; import type { TreeItem } from 'vscode';
import { ThemeIcon } from 'vscode'; import { ThemeIcon } from 'vscode';
import { executeGitCommand } from '../../commands/gitCommands.actions';
import { executeGitCommand } from '../../git/actions';
import { GitUri } from '../../git/gitUri'; import { GitUri } from '../../git/gitUri';
import type { GitLog } from '../../git/models/log'; import type { GitLog } from '../../git/models/log';
import type { SearchQuery, StoredSearchQuery } from '../../git/search'; import type { SearchQuery, StoredSearchQuery } from '../../git/search';

+ 67
- 59
src/views/viewCommands.ts View File

@ -7,11 +7,19 @@ import type {
DiffWithWorkingCommandArgs, DiffWithWorkingCommandArgs,
OpenFileAtRevisionCommandArgs, OpenFileAtRevisionCommandArgs,
} from '../commands'; } from '../commands';
import { GitActions } from '../commands/gitCommands.actions';
import { configuration, FileAnnotationType, ViewShowBranchComparison } from '../configuration'; import { configuration, FileAnnotationType, ViewShowBranchComparison } from '../configuration';
import { Commands, ContextKeys, CoreCommands, CoreGitCommands } from '../constants'; import { Commands, ContextKeys, CoreCommands, CoreGitCommands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { setContext } from '../context'; import { setContext } from '../context';
import { browseAtRevision } from '../git/actions';
import * as BranchActions from '../git/actions/branch';
import * as CommitActions from '../git/actions/commit';
import * as ContributorActions from '../git/actions/contributor';
import * as RemoteActions from '../git/actions/remote';
import * as RepoActions from '../git/actions/repository';
import * as StashActions from '../git/actions/stash';
import * as TagActions from '../git/actions/tag';
import * as WorktreeActions from '../git/actions/worktree';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
import type { GitStashReference } from '../git/models/reference'; import type { GitStashReference } from '../git/models/reference';
import { GitReference, GitRevision } from '../git/models/reference'; import { GitReference, GitRevision } from '../git/models/reference';
@ -288,13 +296,13 @@ export class ViewCommands {
@debug() @debug()
private addAuthors(node?: ViewNode) { private addAuthors(node?: ViewNode) {
return GitActions.Contributor.addAuthors(getNodeRepoPath(node));
return ContributorActions.addAuthors(getNodeRepoPath(node));
} }
@debug() @debug()
private addAuthor(node?: ContributorNode) { private addAuthor(node?: ContributorNode) {
if (node instanceof ContributorNode) { if (node instanceof ContributorNode) {
return GitActions.Contributor.addAuthors(
return ContributorActions.addAuthors(
node.repoPath, node.repoPath,
node.contributor.current ? undefined : node.contributor, node.contributor.current ? undefined : node.contributor,
); );
@ -305,7 +313,7 @@ export class ViewCommands {
@debug() @debug()
private addRemote(node?: ViewNode) { private addRemote(node?: ViewNode) {
return GitActions.Remote.add(getNodeRepoPath(node));
return RemoteActions.add(getNodeRepoPath(node));
} }
@debug() @debug()
@ -313,7 +321,7 @@ export class ViewCommands {
if (!(node instanceof ViewRefFileNode)) return Promise.resolve(); if (!(node instanceof ViewRefFileNode)) return Promise.resolve();
if (node instanceof ResultsFileNode) { if (node instanceof ResultsFileNode) {
return GitActions.Commit.applyChanges(
return CommitActions.applyChanges(
node.file, node.file,
GitReference.create(node.ref1, node.repoPath), GitReference.create(node.ref1, node.repoPath),
GitReference.create(node.ref2, node.repoPath), GitReference.create(node.ref2, node.repoPath),
@ -322,19 +330,19 @@ export class ViewCommands {
if (node.ref == null || node.ref.ref === 'HEAD') return Promise.resolve(); if (node.ref == null || node.ref.ref === 'HEAD') return Promise.resolve();
return GitActions.Commit.applyChanges(node.file, node.ref);
return CommitActions.applyChanges(node.file, node.ref);
} }
@debug() @debug()
private applyStash() { private applyStash() {
return GitActions.Stash.apply();
return StashActions.apply();
} }
@debug() @debug()
private browseRepoAtRevision(node: ViewRefNode, options?: { before?: boolean; openInNewWindow?: boolean }) { private browseRepoAtRevision(node: ViewRefNode, options?: { before?: boolean; openInNewWindow?: boolean }) {
if (!(node instanceof ViewRefNode)) return Promise.resolve(); if (!(node instanceof ViewRefNode)) return Promise.resolve();
return GitActions.browseAtRevision(node.uri, {
return browseAtRevision(node.uri, {
before: options?.before, before: options?.before,
openInNewWindow: options?.openInNewWindow, openInNewWindow: options?.openInNewWindow,
}); });
@ -345,13 +353,13 @@ export class ViewCommands {
if (!(node instanceof CommitNode)) return Promise.resolve(); if (!(node instanceof CommitNode)) return Promise.resolve();
if (nodes != null && nodes.length !== 0) { if (nodes != null && nodes.length !== 0) {
return GitActions.cherryPick(
return RepoActions.cherryPick(
node.repoPath, node.repoPath,
nodes.map(n => n.ref), nodes.map(n => n.ref),
); );
} }
return GitActions.cherryPick(node.repoPath, node.ref);
return RepoActions.cherryPick(node.repoPath, node.ref);
} }
@debug() @debug()
@ -375,7 +383,7 @@ export class ViewCommands {
); );
from = branch; from = branch;
} }
return GitActions.Branch.create(node?.repoPath, from);
return BranchActions.create(node?.repoPath, from);
} }
@debug() @debug()
@ -425,7 +433,7 @@ export class ViewCommands {
); );
from = branch; from = branch;
} }
return GitActions.Tag.create(node?.repoPath, from);
return TagActions.create(node?.repoPath, from);
} }
@debug() @debug()
@ -435,14 +443,14 @@ export class ViewCommands {
} }
if (node != null && !(node instanceof BranchNode)) return undefined; if (node != null && !(node instanceof BranchNode)) return undefined;
return GitActions.Worktree.create(node?.repoPath, undefined, node?.ref);
return WorktreeActions.create(node?.repoPath, undefined, node?.ref);
} }
@debug() @debug()
private deleteBranch(node: BranchNode) { private deleteBranch(node: BranchNode) {
if (!(node instanceof BranchNode)) return Promise.resolve(); if (!(node instanceof BranchNode)) return Promise.resolve();
return GitActions.Branch.remove(node.repoPath, node.branch);
return BranchActions.remove(node.repoPath, node.branch);
} }
@debug() @debug()
@ -453,34 +461,34 @@ export class ViewCommands {
const sorted = nodes.sort((a, b) => parseInt(b.commit.number, 10) - parseInt(a.commit.number, 10)); const sorted = nodes.sort((a, b) => parseInt(b.commit.number, 10) - parseInt(a.commit.number, 10));
return sequentialize( return sequentialize(
GitActions.Stash.drop,
StashActions.drop,
sorted.map<[string, GitStashReference]>(n => [n.repoPath, n.commit]), sorted.map<[string, GitStashReference]>(n => [n.repoPath, n.commit]),
this, this,
); );
} }
return GitActions.Stash.drop(node.repoPath, node.commit);
return StashActions.drop(node.repoPath, node.commit);
} }
@debug() @debug()
private deleteTag(node: TagNode) { private deleteTag(node: TagNode) {
if (!(node instanceof TagNode)) return Promise.resolve(); if (!(node instanceof TagNode)) return Promise.resolve();
return GitActions.Tag.remove(node.repoPath, node.tag);
return TagActions.remove(node.repoPath, node.tag);
} }
@debug() @debug()
private async deleteWorktree(node: WorktreeNode) { private async deleteWorktree(node: WorktreeNode) {
if (!(node instanceof WorktreeNode)) return undefined; if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.remove(node.repoPath, node.worktree.uri);
return WorktreeActions.remove(node.repoPath, node.worktree.uri);
} }
@debug() @debug()
private fetch(node: RemoteNode | RepositoryNode | RepositoryFolderNode | BranchNode | BranchTrackingStatusNode) { private fetch(node: RemoteNode | RepositoryNode | RepositoryFolderNode | BranchNode | BranchTrackingStatusNode) {
if (node instanceof RepositoryNode || node instanceof RepositoryFolderNode) return GitActions.fetch(node.repo);
if (node instanceof RemoteNode) return GitActions.Remote.fetch(node.remote.repoPath, node.remote.name);
if (node instanceof RepositoryNode || node instanceof RepositoryFolderNode) return RepoActions.fetch(node.repo);
if (node instanceof RemoteNode) return RemoteActions.fetch(node.remote.repoPath, node.remote.name);
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) { if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
return GitActions.fetch(node.repoPath, node.root ? undefined : node.branch);
return RepoActions.fetch(node.repoPath, node.root ? undefined : node.branch);
} }
return Promise.resolve(); return Promise.resolve();
@ -532,7 +540,7 @@ export class ViewCommands {
private merge(node: BranchNode | TagNode) { private merge(node: BranchNode | TagNode) {
if (!(node instanceof BranchNode) && !(node instanceof TagNode)) return Promise.resolve(); if (!(node instanceof BranchNode) && !(node instanceof TagNode)) return Promise.resolve();
return GitActions.merge(node.repoPath, node instanceof BranchNode ? node.branch : node.tag);
return RepoActions.merge(node.repoPath, node instanceof BranchNode ? node.branch : node.tag);
} }
@debug() @debug()
@ -564,27 +572,27 @@ export class ViewCommands {
private openWorktree(node: WorktreeNode, options?: { location?: OpenWorkspaceLocation }) { private openWorktree(node: WorktreeNode, options?: { location?: OpenWorkspaceLocation }) {
if (!(node instanceof WorktreeNode)) return undefined; if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.open(node.worktree, options);
return WorktreeActions.open(node.worktree, options);
} }
@debug() @debug()
private pruneRemote(node: RemoteNode) { private pruneRemote(node: RemoteNode) {
if (!(node instanceof RemoteNode)) return Promise.resolve(); if (!(node instanceof RemoteNode)) return Promise.resolve();
return GitActions.Remote.prune(node.repo, node.remote.name);
return RemoteActions.prune(node.repo, node.remote.name);
} }
@debug() @debug()
private async removeRemote(node: RemoteNode) { private async removeRemote(node: RemoteNode) {
if (!(node instanceof RemoteNode)) return Promise.resolve(); if (!(node instanceof RemoteNode)) return Promise.resolve();
return GitActions.Remote.remove(node.repo, node.remote.name);
return RemoteActions.remove(node.repo, node.remote.name);
} }
@debug() @debug()
private publishBranch(node: BranchNode | BranchTrackingStatusNode) { private publishBranch(node: BranchNode | BranchTrackingStatusNode) {
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) { if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
return GitActions.push(node.repoPath, undefined, node.branch);
return RepoActions.push(node.repoPath, undefined, node.branch);
} }
return Promise.resolve(); return Promise.resolve();
} }
@ -599,9 +607,9 @@ export class ViewCommands {
@debug() @debug()
private pull(node: RepositoryNode | RepositoryFolderNode | BranchNode | BranchTrackingStatusNode) { private pull(node: RepositoryNode | RepositoryFolderNode | BranchNode | BranchTrackingStatusNode) {
if (node instanceof RepositoryNode || node instanceof RepositoryFolderNode) return GitActions.pull(node.repo);
if (node instanceof RepositoryNode || node instanceof RepositoryFolderNode) return RepoActions.pull(node.repo);
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) { if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
return GitActions.pull(node.repoPath, node.root ? undefined : node.branch);
return RepoActions.pull(node.repoPath, node.root ? undefined : node.branch);
} }
return Promise.resolve(); return Promise.resolve();
@ -619,16 +627,16 @@ export class ViewCommands {
force?: boolean, force?: boolean,
) { ) {
if (node instanceof RepositoryNode || node instanceof RepositoryFolderNode) { if (node instanceof RepositoryNode || node instanceof RepositoryFolderNode) {
return GitActions.push(node.repo, force);
return RepoActions.push(node.repo, force);
} }
if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) { if (node instanceof BranchNode || node instanceof BranchTrackingStatusNode) {
return GitActions.push(node.repoPath, force, node.root ? undefined : node.branch);
return RepoActions.push(node.repoPath, force, node.root ? undefined : node.branch);
} }
if (node instanceof CommitNode || node instanceof FileRevisionAsCommitNode) { if (node instanceof CommitNode || node instanceof FileRevisionAsCommitNode) {
if (node.isTip) { if (node.isTip) {
return GitActions.push(node.repoPath, force);
return RepoActions.push(node.repoPath, force);
} }
return this.pushToCommit(node); return this.pushToCommit(node);
@ -641,7 +649,7 @@ export class ViewCommands {
private pushToCommit(node: CommitNode | FileRevisionAsCommitNode) { private pushToCommit(node: CommitNode | FileRevisionAsCommitNode) {
if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve(); if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve();
return GitActions.push(node.repoPath, false, node.commit);
return RepoActions.push(node.repoPath, false, node.commit);
} }
@debug() @debug()
@ -655,7 +663,7 @@ export class ViewCommands {
return Promise.resolve(); return Promise.resolve();
} }
return GitActions.rebase(node.repoPath, node.ref);
return RepoActions.rebase(node.repoPath, node.ref);
} }
@debug() @debug()
@ -665,7 +673,7 @@ export class ViewCommands {
const upstream = node instanceof BranchNode ? node.branch.upstream?.name : node.status.upstream; const upstream = node instanceof BranchNode ? node.branch.upstream?.name : node.status.upstream;
if (upstream == null) return Promise.resolve(); if (upstream == null) return Promise.resolve();
return GitActions.rebase(
return RepoActions.rebase(
node.repoPath, node.repoPath,
GitReference.create(upstream, node.repoPath, { GitReference.create(upstream, node.repoPath, {
refType: 'branch', refType: 'branch',
@ -679,14 +687,14 @@ export class ViewCommands {
private renameBranch(node: BranchNode) { private renameBranch(node: BranchNode) {
if (!(node instanceof BranchNode)) return Promise.resolve(); if (!(node instanceof BranchNode)) return Promise.resolve();
return GitActions.Branch.rename(node.repoPath, node.branch);
return BranchActions.rename(node.repoPath, node.branch);
} }
@debug() @debug()
private resetCommit(node: CommitNode | FileRevisionAsCommitNode) { private resetCommit(node: CommitNode | FileRevisionAsCommitNode) {
if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve(); if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve();
return GitActions.reset(
return RepoActions.reset(
node.repoPath, node.repoPath,
GitReference.create(`${node.ref.ref}^`, node.ref.repoPath, { GitReference.create(`${node.ref.ref}^`, node.ref.repoPath, {
refType: 'revision', refType: 'revision',
@ -700,28 +708,28 @@ export class ViewCommands {
private resetToCommit(node: CommitNode | FileRevisionAsCommitNode) { private resetToCommit(node: CommitNode | FileRevisionAsCommitNode) {
if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve(); if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve();
return GitActions.reset(node.repoPath, node.ref);
return RepoActions.reset(node.repoPath, node.ref);
} }
@debug() @debug()
private restore(node: ViewRefFileNode) { private restore(node: ViewRefFileNode) {
if (!(node instanceof ViewRefFileNode)) return Promise.resolve(); if (!(node instanceof ViewRefFileNode)) return Promise.resolve();
return GitActions.Commit.restoreFile(node.file, node.ref);
return CommitActions.restoreFile(node.file, node.ref);
} }
@debug() @debug()
private revealWorktreeInExplorer(node: WorktreeNode) { private revealWorktreeInExplorer(node: WorktreeNode) {
if (!(node instanceof WorktreeNode)) return undefined; if (!(node instanceof WorktreeNode)) return undefined;
return GitActions.Worktree.revealInFileExplorer(node.worktree);
return WorktreeActions.revealInFileExplorer(node.worktree);
} }
@debug() @debug()
private revert(node: CommitNode | FileRevisionAsCommitNode) { private revert(node: CommitNode | FileRevisionAsCommitNode) {
if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve(); if (!(node instanceof CommitNode) && !(node instanceof FileRevisionAsCommitNode)) return Promise.resolve();
return GitActions.revert(node.repoPath, node.ref);
return RepoActions.revert(node.repoPath, node.ref);
} }
@debug() @debug()
@ -780,19 +788,19 @@ export class ViewCommands {
@debug() @debug()
private switch(node?: ViewNode) { private switch(node?: ViewNode) {
return GitActions.switchTo(getNodeRepoPath(node));
return RepoActions.switchTo(getNodeRepoPath(node));
} }
@debug() @debug()
private switchTo(node?: ViewNode) { private switchTo(node?: ViewNode) {
if (node instanceof ViewRefNode) { if (node instanceof ViewRefNode) {
return GitActions.switchTo(
return RepoActions.switchTo(
node.repoPath, node.repoPath,
node instanceof BranchNode && node.branch.current ? undefined : node.ref, node instanceof BranchNode && node.branch.current ? undefined : node.ref,
); );
} }
return GitActions.switchTo(getNodeRepoPath(node));
return RepoActions.switchTo(getNodeRepoPath(node));
} }
@debug() @debug()
@ -964,7 +972,7 @@ export class ViewCommands {
const { files: diff } = await node.getFilesQueryResults(); const { files: diff } = await node.getFilesQueryResults();
if (diff == null || diff.length === 0) return undefined; if (diff == null || diff.length === 0) return undefined;
return GitActions.Commit.openAllChanges(
return CommitActions.openAllChanges(
diff, diff,
{ {
repoPath: node.repoPath, repoPath: node.repoPath,
@ -975,7 +983,7 @@ export class ViewCommands {
); );
} }
return GitActions.Commit.openAllChanges(node.commit, options);
return CommitActions.openAllChanges(node.commit, options);
} }
@debug() @debug()
@ -1030,7 +1038,7 @@ export class ViewCommands {
} }
// TODO@eamodio Revisit this // TODO@eamodio Revisit this
// return GitActions.Commit.openChanges(node.file, node instanceof ViewRefFileNode ? node.ref : node.commit, {
// return CommitActions.openChanges(node.file, node instanceof ViewRefFileNode ? node.ref : node.commit, {
// preserveFocus: true, // preserveFocus: true,
// preview: false, // preview: false,
// }); // });
@ -1049,7 +1057,7 @@ export class ViewCommands {
const { files: diff } = await node.getFilesQueryResults(); const { files: diff } = await node.getFilesQueryResults();
if (diff == null || diff.length === 0) return undefined; if (diff == null || diff.length === 0) return undefined;
return GitActions.Commit.openAllChangesWithWorking(
return CommitActions.openAllChangesWithWorking(
diff, diff,
{ {
repoPath: node.repoPath, repoPath: node.repoPath,
@ -1059,7 +1067,7 @@ export class ViewCommands {
); );
} }
return GitActions.Commit.openAllChangesWithWorking(node.commit, options);
return CommitActions.openAllChangesWithWorking(node.commit, options);
// options = { preserveFocus: false, preview: false, ...options }; // options = { preserveFocus: false, preview: false, ...options };
@ -1140,14 +1148,17 @@ export class ViewCommands {
} }
} }
return GitActions.Commit.openChangesWithWorking(node.file, { repoPath: node.repoPath, ref: node.ref.ref });
return CommitActions.openChangesWithWorking(node.file, {
repoPath: node.repoPath,
ref: node.ref.ref,
});
} }
@debug() @debug()
private async openPreviousChangesWithWorking(node: ViewRefFileNode) { private async openPreviousChangesWithWorking(node: ViewRefFileNode) {
if (!(node instanceof ViewRefFileNode)) return Promise.resolve(); if (!(node instanceof ViewRefFileNode)) return Promise.resolve();
return GitActions.Commit.openChangesWithWorking(node.file, {
return CommitActions.openChangesWithWorking(node.file, {
repoPath: node.repoPath, repoPath: node.repoPath,
ref: `${node.ref.ref}^`, ref: `${node.ref.ref}^`,
}); });
@ -1168,7 +1179,7 @@ export class ViewCommands {
return Promise.resolve(); return Promise.resolve();
} }
return GitActions.Commit.openFile(node.uri, {
return CommitActions.openFile(node.uri, {
preserveFocus: true, preserveFocus: true,
preview: false, preview: false,
...options, ...options,
@ -1185,10 +1196,10 @@ export class ViewCommands {
const { files: diff } = await node.getFilesQueryResults(); const { files: diff } = await node.getFilesQueryResults();
if (diff == null || diff.length === 0) return undefined; if (diff == null || diff.length === 0) return undefined;
return GitActions.Commit.openFiles(diff, node.repoPath, node.ref1 || node.ref2);
return CommitActions.openFiles(diff, node.repoPath, node.ref1 || node.ref2);
} }
return GitActions.Commit.openFiles(node.commit);
return CommitActions.openFiles(node.commit);
} }
@debug() @debug()
@ -1231,10 +1242,7 @@ export class ViewCommands {
} }
} }
return GitActions.Commit.openFileAtRevision(
uri,
options.showOptions ?? { preserveFocus: true, preview: false },
);
return CommitActions.openFileAtRevision(uri, options.showOptions ?? { preserveFocus: true, preview: false });
} }
@debug() @debug()
@ -1247,9 +1255,9 @@ export class ViewCommands {
const { files: diff } = await node.getFilesQueryResults(); const { files: diff } = await node.getFilesQueryResults();
if (diff == null || diff.length === 0) return undefined; if (diff == null || diff.length === 0) return undefined;
return GitActions.Commit.openFilesAtRevision(diff, node.repoPath, node.ref1, node.ref2);
return CommitActions.openFilesAtRevision(diff, node.repoPath, node.ref1, node.ref2);
} }
return GitActions.Commit.openFilesAtRevision(node.commit);
return CommitActions.openFilesAtRevision(node.commit);
} }
} }

+ 14
- 7
src/webviews/commitDetails/commitDetailsWebviewView.ts View File

@ -2,12 +2,19 @@ import type { CancellationToken, ConfigurationChangeEvent, TextDocumentShowOptio
import { CancellationTokenSource, Disposable, Uri, ViewColumn, window } from 'vscode'; import { CancellationTokenSource, Disposable, Uri, ViewColumn, window } from 'vscode';
import { serializeAutolink } from '../../annotations/autolinks'; import { serializeAutolink } from '../../annotations/autolinks';
import type { CopyShaToClipboardCommandArgs } from '../../commands'; import type { CopyShaToClipboardCommandArgs } from '../../commands';
import { executeGitCommand, GitActions } from '../../commands/gitCommands.actions';
import { configuration } from '../../configuration'; import { configuration } from '../../configuration';
import { Commands, ContextKeys, CoreCommands } from '../../constants'; import { Commands, ContextKeys, CoreCommands } from '../../constants';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { getContext } from '../../context'; import { getContext } from '../../context';
import type { CommitSelectedEvent } from '../../eventBus'; import type { CommitSelectedEvent } from '../../eventBus';
import { executeGitCommand } from '../../git/actions';
import {
openChanges,
openChangesWithWorking,
openFile,
openFileOnRemote,
showDetailsQuickPick,
} from '../../git/actions/commit';
import { CommitFormatter } from '../../git/formatters/commitFormatter'; import { CommitFormatter } from '../../git/formatters/commitFormatter';
import type { GitCommit } from '../../git/models/commit'; import type { GitCommit } from '../../git/models/commit';
import { isCommit } from '../../git/models/commit'; import { isCommit } from '../../git/models/commit';
@ -787,7 +794,7 @@ export class CommitDetailsWebviewView extends WebviewViewBase
private showCommitActions() { private showCommitActions() {
if (this._context.commit == null || this._context.commit.isUncommitted) return; if (this._context.commit == null || this._context.commit.isUncommitted) return;
void GitActions.Commit.showDetailsQuickPick(this._context.commit);
void showDetailsQuickPick(this._context.commit);
} }
private async showFileActions(params: FileActionParams) { private async showFileActions(params: FileActionParams) {
@ -797,7 +804,7 @@ export class CommitDetailsWebviewView extends WebviewViewBase
const [commit, file] = result; const [commit, file] = result;
this.updatePinned(true, true); this.updatePinned(true, true);
void GitActions.Commit.showDetailsQuickPick(commit, file);
void showDetailsQuickPick(commit, file);
} }
private async openFileComparisonWithWorking(params: FileActionParams) { private async openFileComparisonWithWorking(params: FileActionParams) {
@ -807,7 +814,7 @@ export class CommitDetailsWebviewView extends WebviewViewBase
const [commit, file] = result; const [commit, file] = result;
this.updatePinned(true, true); this.updatePinned(true, true);
void GitActions.Commit.openChangesWithWorking(file.path, commit, {
void openChangesWithWorking(file.path, commit, {
preserveFocus: true, preserveFocus: true,
preview: true, preview: true,
...this.getShowOptions(params), ...this.getShowOptions(params),
@ -821,7 +828,7 @@ export class CommitDetailsWebviewView extends WebviewViewBase
const [commit, file] = result; const [commit, file] = result;
this.updatePinned(true, true); this.updatePinned(true, true);
void GitActions.Commit.openChanges(file.path, commit, {
void openChanges(file.path, commit, {
preserveFocus: true, preserveFocus: true,
preview: true, preview: true,
...this.getShowOptions(params), ...this.getShowOptions(params),
@ -836,7 +843,7 @@ export class CommitDetailsWebviewView extends WebviewViewBase
const [commit, file] = result; const [commit, file] = result;
this.updatePinned(true, true); this.updatePinned(true, true);
void GitActions.Commit.openFile(file.path, commit, {
void openFile(file.path, commit, {
preserveFocus: true, preserveFocus: true,
preview: true, preview: true,
...this.getShowOptions(params), ...this.getShowOptions(params),
@ -849,7 +856,7 @@ export class CommitDetailsWebviewView extends WebviewViewBase
const [commit, file] = result; const [commit, file] = result;
void GitActions.Commit.openFileOnRemote(file.path, commit);
void openFileOnRemote(file.path, commit);
} }
private getShowOptions(params: FileActionParams): TextDocumentShowOptions | undefined { private getShowOptions(params: FileActionParams): TextDocumentShowOptions | undefined {

Loading…
Cancel
Save