Browse Source

Avoids more circular references

main
Eric Amodio 2 years ago
parent
commit
7b5c5ffbe4
148 changed files with 1631 additions and 1555 deletions
  1. +4
    -4
      src/annotations/annotations.ts
  2. +1
    -1
      src/annotations/blameAnnotationProvider.ts
  3. +8
    -8
      src/annotations/gutterBlameAnnotationProvider.ts
  4. +3
    -3
      src/api/actionRunners.ts
  5. +2
    -1
      src/commands/addAuthors.ts
  6. +0
    -17
      src/commands/base.ts
  7. +2
    -2
      src/commands/browseRepoAtRevision.ts
  8. +3
    -3
      src/commands/closeUnchangedFiles.ts
  9. +2
    -1
      src/commands/closeView.ts
  10. +3
    -2
      src/commands/compareWith.ts
  11. +3
    -2
      src/commands/copyCurrentBranch.ts
  12. +3
    -3
      src/commands/copyMessageToClipboard.ts
  13. +3
    -3
      src/commands/copyShaToClipboard.ts
  14. +2
    -2
      src/commands/createPullRequestOnRemote.ts
  15. +2
    -2
      src/commands/diffLineWithPrevious.ts
  16. +2
    -2
      src/commands/diffLineWithWorking.ts
  17. +2
    -2
      src/commands/diffWith.ts
  18. +2
    -2
      src/commands/diffWithNext.ts
  19. +2
    -2
      src/commands/diffWithPrevious.ts
  20. +6
    -5
      src/commands/diffWithRevision.ts
  21. +7
    -6
      src/commands/diffWithRevisionFrom.ts
  22. +2
    -2
      src/commands/diffWithWorking.ts
  23. +4
    -4
      src/commands/externalDiff.ts
  24. +5
    -4
      src/commands/git/branch.ts
  25. +1
    -1
      src/commands/git/cherry-pick.ts
  26. +2
    -2
      src/commands/git/coauthors.ts
  27. +1
    -1
      src/commands/git/fetch.ts
  28. +5
    -5
      src/commands/git/log.ts
  29. +8
    -7
      src/commands/git/merge.ts
  30. +2
    -1
      src/commands/git/pull.ts
  31. +2
    -1
      src/commands/git/push.ts
  32. +5
    -6
      src/commands/git/rebase.ts
  33. +1
    -1
      src/commands/git/reset.ts
  34. +1
    -1
      src/commands/git/revert.ts
  35. +5
    -5
      src/commands/git/search.ts
  36. +3
    -1
      src/commands/git/show.ts
  37. +6
    -5
      src/commands/git/stash.ts
  38. +4
    -3
      src/commands/git/status.ts
  39. +2
    -7
      src/commands/git/switch.ts
  40. +4
    -6
      src/commands/git/tag.ts
  41. +1
    -1
      src/commands/gitCommands.actions.ts
  42. +22
    -121
      src/commands/gitCommands.ts
  43. +125
    -0
      src/commands/gitCommands.utils.ts
  44. +2
    -1
      src/commands/inviteToLiveShare.ts
  45. +2
    -1
      src/commands/logging.ts
  46. +2
    -2
      src/commands/openAssociatedPullRequestOnRemote.ts
  47. +5
    -3
      src/commands/openBranchOnRemote.ts
  48. +3
    -3
      src/commands/openBranchesOnRemote.ts
  49. +5
    -4
      src/commands/openChangedFiles.ts
  50. +1
    -2
      src/commands/openCommitOnRemote.ts
  51. +2
    -2
      src/commands/openComparisonOnRemote.ts
  52. +4
    -2
      src/commands/openDirectoryCompare.ts
  53. +6
    -4
      src/commands/openFileAtRevision.ts
  54. +7
    -5
      src/commands/openFileAtRevisionFrom.ts
  55. +2
    -1
      src/commands/openFileFromRemote.ts
  56. +6
    -7
      src/commands/openFileOnRemote.ts
  57. +2
    -1
      src/commands/openIssueOnRemote.ts
  58. +20
    -17
      src/commands/openOnRemote.ts
  59. +2
    -1
      src/commands/openPullRequestOnRemote.ts
  60. +3
    -3
      src/commands/openRepoOnRemote.ts
  61. +2
    -1
      src/commands/openRevisionFile.ts
  62. +2
    -1
      src/commands/openWorkingFile.ts
  63. +13
    -11
      src/commands/quickCommand.steps.ts
  64. +1
    -1
      src/commands/quickCommand.ts
  65. +2
    -1
      src/commands/rebaseEditor.ts
  66. +2
    -2
      src/commands/refreshHover.ts
  67. +5
    -4
      src/commands/remoteProviders.ts
  68. +2
    -1
      src/commands/repositories.ts
  69. +2
    -1
      src/commands/resetAvatarCache.ts
  70. +2
    -1
      src/commands/resetSuppressedWarnings.ts
  71. +2
    -1
      src/commands/searchCommits.ts
  72. +2
    -2
      src/commands/setViewsLayout.ts
  73. +4
    -5
      src/commands/showCommitsInView.ts
  74. +2
    -1
      src/commands/showLastQuickPick.ts
  75. +2
    -1
      src/commands/showQuickBranchHistory.ts
  76. +2
    -7
      src/commands/showQuickCommit.ts
  77. +2
    -7
      src/commands/showQuickCommitFile.ts
  78. +3
    -2
      src/commands/showQuickFileHistory.ts
  79. +2
    -1
      src/commands/showQuickRepoStatus.ts
  80. +2
    -1
      src/commands/showQuickStashList.ts
  81. +2
    -2
      src/commands/showView.ts
  82. +2
    -2
      src/commands/stashApply.ts
  83. +1
    -1
      src/commands/stashSave.ts
  84. +4
    -3
      src/commands/switchMode.ts
  85. +2
    -1
      src/commands/toggleCodeLens.ts
  86. +2
    -1
      src/commands/toggleFileAnnotations.ts
  87. +2
    -1
      src/commands/toggleLineBlame.ts
  88. +21
    -0
      src/constants.ts
  89. +1
    -2
      src/extension.ts
  90. +14
    -2
      src/git/formatters/commitFormatter.ts
  91. +25
    -18
      src/git/formatters/formatter.ts
  92. +1
    -1
      src/git/parsers/branchParser.ts
  93. +3
    -2
      src/git/parsers/logParser.ts
  94. +1
    -1
      src/git/parsers/reflogParser.ts
  95. +1
    -1
      src/git/parsers/remoteParser.ts
  96. +1
    -1
      src/git/parsers/tagParser.ts
  97. +1
    -1
      src/git/parsers/treeParser.ts
  98. +11
    -17
      src/git/remotes/custom.ts
  99. +0
    -15
      src/quickpicks.ts
  100. +4
    -7
      src/quickpicks/commitPicker.ts

+ 4
- 4
src/annotations/annotations.ts View File

@ -16,7 +16,7 @@ import { Colors, GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter } from '../git/formatters';
import { GitCommit } from '../git/models';
import { Strings } from '../system';
import { getWidth, interpolate, pad } from '../system/string';
import { toRgba } from '../webviews/apps/shared/colors';
export interface ComputedHeatmap {
@ -157,7 +157,7 @@ export class Annotations {
}
const message = CommitFormatter.fromTemplate(format, commit, dateFormatOrFormatOptions);
decoration.renderOptions!.before!.contentText = Strings.pad(message.replace(/ /g, GlyphChars.Space), 1, 1);
decoration.renderOptions!.before!.contentText = pad(message.replace(/ /g, GlyphChars.Space), 1, 1);
return decoration;
}
@ -185,7 +185,7 @@ export class Annotations {
if (chars >= 0) {
// Add the chars of the template string (without tokens)
chars += Strings.getWidth(Strings.interpolate(format, undefined));
chars += getWidth(interpolate(format, undefined));
// If we have chars, add a bit of padding
if (chars > 0) {
chars += 3;
@ -251,7 +251,7 @@ export class Annotations {
after: {
backgroundColor: new ThemeColor(Colors.TrailingLineBackgroundColor),
color: new ThemeColor(Colors.TrailingLineForegroundColor),
contentText: Strings.pad(message.replace(/ /g, GlyphChars.Space), 1, 1),
contentText: pad(message.replace(/ /g, GlyphChars.Space), 1, 1),
fontWeight: 'normal',
fontStyle: 'normal',
// Pull the decoration out of the document flow if we want to be scrollable

+ 1
- 1
src/annotations/blameAnnotationProvider.ts View File

@ -4,7 +4,7 @@ import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { GitBlame, GitCommit } from '../git/models';
import { Hovers } from '../hovers/hovers';
import { log } from '../system';
import { log } from '../system/decorators/log';
import { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker';
import { AnnotationProviderBase } from './annotationProvider';
import { ComputedHeatmap, getHeatmapColors } from './annotations';

+ 8
- 8
src/annotations/gutterBlameAnnotationProvider.ts View File

@ -5,9 +5,11 @@ import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter } from '../git/formatters';
import { GitBlame, GitCommit } from '../git/models';
import { Logger } from '../logger';
import { Arrays, Iterables, Strings } from '../system';
import { filterMap } from '../system/array';
import { log } from '../system/decorators/log';
import { first } from '../system/iterable';
import { Stopwatch } from '../system/stopwatch';
import { getTokensFromTemplate, getWidth, TokenOptions } from '../system/string';
import { GitDocumentState } from '../trackers/gitDocumentTracker';
import { TrackedDocument } from '../trackers/trackedDocument';
import { AnnotationContext } from './annotationProvider';
@ -44,8 +46,8 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
const cfg = this.container.config.blame;
// Precalculate the formatting options so we don't need to do it on each iteration
const tokenOptions = Strings.getTokensFromTemplate(cfg.format).reduce<{
[token: string]: Strings.TokenOptions | undefined;
const tokenOptions = getTokensFromTemplate(cfg.format).reduce<{
[token: string]: TokenOptions | undefined;
}>((map, token) => {
map[token.key] = token.options;
return map;
@ -102,9 +104,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
gutter.renderOptions = {
before: {
...gutter.renderOptions!.before,
contentText: GlyphChars.Space.repeat(
Strings.getWidth(gutter.renderOptions!.before!.contentText!),
),
contentText: GlyphChars.Space.repeat(getWidth(gutter.renderOptions!.before!.contentText!)),
},
};
@ -191,7 +191,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
sha = commitLine?.sha;
}
} else {
sha = Iterables.first(blame.commits.values()).sha;
sha = first(blame.commits.values()).sha;
}
if (!sha) {
@ -199,7 +199,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
return;
}
const highlightDecorationRanges = Arrays.filterMap(blame.lines, l =>
const highlightDecorationRanges = filterMap(blame.lines, l =>
l.sha === sha
? // editor lines are 0-based
this.editor.document.validateRange(new Range(l.line - 1, 0, l.line - 1, Number.MAX_SAFE_INTEGER))

+ 3
- 3
src/api/actionRunners.ts View File

@ -3,8 +3,8 @@ import { Config, configuration } from '../configuration';
import { Commands, ContextKeys } from '../constants';
import { Container } from '../container';
import { setContext } from '../context';
import { getQuickPickIgnoreFocusOut } from '../quickpicks';
import { Strings } from '../system';
import { sortCompare } from '../system/string';
import { getQuickPickIgnoreFocusOut } from '../system/utils';
import type { Action, ActionContext, ActionRunner } from './gitlens';
type Actions = ActionContext['type'];
@ -255,7 +255,7 @@ export class ActionRunners implements Disposable {
if (runners.length > 1 || runners.every(r => r.type !== ActionRunnerType.BuiltIn)) {
const items: (ActionRunnerQuickPickItem | NoActionRunnersQuickPickItem)[] = runners
// .filter(r => r.when(context))
.sort((a, b) => a.order - b.order || Strings.sortCompare(a.name, b.name))
.sort((a, b) => a.order - b.order || sortCompare(a.name, b.name))
.map(r => new ActionRunnerQuickPickItem(r, context));
if (items.length === 0) {

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

@ -1,7 +1,8 @@
import { SourceControl } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command, Command } from './base';
import { command } from '../system/command';
import { Command } from './base';
import { executeGitCommand } from './gitCommands.actions';
@command()

+ 0
- 17
src/commands/base.ts View File

@ -12,7 +12,6 @@ import {
} from 'vscode';
import type { ActionContext } from '../api/gitlens';
import { Commands } from '../constants';
import { Container } from '../container';
import {
GitBranch,
GitCommit,
@ -26,22 +25,6 @@ import {
} from '../git/models';
import { ViewNode, ViewRefNode } from '../views/nodes';
interface CommandConstructor {
new (container: Container): Command;
}
const registrableCommands: CommandConstructor[] = [];
export function command(): ClassDecorator {
return (target: any) => {
registrableCommands.push(target);
};
}
export function registerCommands(container: Container): Disposable[] {
return registrableCommands.map(c => new c(container));
}
export function getCommandUri(uri?: Uri, editor?: TextEditor): Uri | undefined {
// Always use the editor.uri (if we have one), so we are correct for a split diff
return editor?.document?.uri ?? uri;

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

@ -4,10 +4,10 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { executeCoreCommand } from '../system/command';
import { command, executeCoreCommand } from '../system/command';
import { basename } from '../system/path';
import { openWorkspace, OpenWorkspaceLocation } from '../system/utils';
import { ActiveEditorCommand, command, CommandContext, getCommandUri } from './base';
import { ActiveEditorCommand, CommandContext, getCommandUri } from './base';
export interface BrowseRepoAtRevisionCommandArgs {
uri?: Uri;

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

@ -4,10 +4,10 @@ import { Commands, CoreCommands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { RepositoryPicker } from '../quickpicks';
import { executeCoreCommand } from '../system/command';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command, executeCoreCommand } from '../system/command';
import { debounce } from '../system/function';
import { Command, command } from './base';
import { Command } from './base';
export interface CloseUnchangedFilesCommandArgs {
uris?: Uri[];

+ 2
- 1
src/commands/closeView.ts View File

@ -2,7 +2,8 @@ import { Commands, ContextKeys } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { SyncedState } from '../storage';
import { command, Command, CommandContext } from './base';
import { command } from '../system/command';
import { Command, CommandContext } from './base';
@command()
export class CloseViewCommand extends Command {

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

@ -3,8 +3,9 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { RepositoryPicker } from '../quickpicks';
import { ActiveEditorCommand, command, CommandContext, getCommandUri } from './base';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command } from '../system/command';
import { ActiveEditorCommand, CommandContext, getCommandUri } from './base';
export interface CompareWithCommandArgs {
ref1?: string;

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

@ -3,8 +3,9 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { RepositoryPicker } from '../quickpicks';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
@command()
export class CopyCurrentBranchCommand extends ActiveEditorCommand {

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

@ -4,10 +4,10 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { command } from '../system/command';
import { first } from '../system/iterable';
import {
ActiveEditorCommand,
command,
CommandContext,
getCommandUri,
isCommandContextViewNodeHasBranch,
@ -60,7 +60,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
const log = await this.container.git.getLog(repoPath, { limit: 1 });
if (log == null) return;
const commit = Iterables.first(log.commits.values());
const commit = first(log.commits.values());
if (commit?.message == null) return;
args.message = commit.message;

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

@ -4,10 +4,10 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { command } from '../system/command';
import { first } from '../system/iterable';
import {
ActiveEditorCommand,
command,
CommandContext,
getCommandUri,
isCommandContextViewNodeHasBranch,
@ -58,7 +58,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
const log = await this.container.git.getLog(repoPath, { limit: 1 });
if (log == null) return;
args.sha = Iterables.first(log.commits.values()).sha;
args.sha = first(log.commits.values()).sha;
} else if (args.sha == null) {
const blameline = editor?.selection.active.line ?? 0;
if (blameline < 0) return;

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

@ -2,8 +2,8 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { GitRemote } from '../git/models';
import { RemoteProvider, RemoteResource, RemoteResourceType } from '../git/remotes/provider';
import { executeCommand } from '../system/command';
import { Command, command } from './base';
import { command, executeCommand } from '../system/command';
import { Command } from './base';
import { OpenOnRemoteCommandArgs } from './openOnRemote';
export interface CreatePullRequestOnRemoteCommandArgs {

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

@ -5,8 +5,8 @@ import { GitUri } from '../git/gitUri';
import { GitCommit } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffLineWithPreviousCommandArgs {

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

@ -5,8 +5,8 @@ import { GitUri } from '../git/gitUri';
import { GitCommit, GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffLineWithWorkingCommandArgs {

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

@ -4,9 +4,9 @@ import type { Container } from '../container';
import { GitCommit, GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { executeCoreCommand } from '../system/command';
import { command, executeCoreCommand } from '../system/command';
import { basename } from '../system/path';
import { command, Command } from './base';
import { Command } from './base';
export interface DiffWithCommandArgsRevision {
sha: string;

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

@ -5,8 +5,8 @@ import { GitUri } from '../git/gitUri';
import { GitCommit } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, CommandContext, getCommandUri } from './base';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, CommandContext, getCommandUri } from './base';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithNextCommandArgs {

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

@ -5,9 +5,9 @@ import { GitUri } from '../git/gitUri';
import { GitCommit, GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { executeCommand } from '../system/command';
import { command, executeCommand } from '../system/command';
import { findOrOpenEditor } from '../system/utils';
import { ActiveEditorCommand, command, CommandContext, getCommandUri } from './base';
import { ActiveEditorCommand, CommandContext, getCommandUri } from './base';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithPreviousCommandArgs {

+ 6
- 5
src/commands/diffWithRevision.ts View File

@ -5,10 +5,11 @@ import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, CommitPicker } from '../quickpicks';
import { Strings } from '../system';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { CommitPicker } from '../quickpicks/commitPicker';
import { CommandQuickPickItem } from '../quickpicks/items/common';
import { command, executeCommand } from '../system/command';
import { pad } from '../system/string';
import { ActiveEditorCommand, getCommandUri } from './base';
import { DiffWithCommandArgs } from './diffWith';
import { DiffWithRevisionFromCommandArgs } from './diffWithRevisionFrom';
@ -45,7 +46,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
: undefined),
);
const title = `Open Changes with Revision${Strings.pad(GlyphChars.Dot, 2, 2)}`;
const title = `Open Changes with Revision${pad(GlyphChars.Dot, 2, 2)}`;
const pick = await CommitPicker.show(
log,
`${title}${gitUri.getFormattedFileName({

+ 7
- 6
src/commands/diffWithRevisionFrom.ts View File

@ -4,11 +4,12 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { GitReference, GitRevision } from '../git/models';
import { Messages } from '../messages';
import { ReferencePicker, StashPicker } from '../quickpicks';
import { Strings } from '../system';
import { executeCommand } from '../system/command';
import { StashPicker } from '../quickpicks/commitPicker';
import { ReferencePicker } from '../quickpicks/referencePicker';
import { command, executeCommand } from '../system/command';
import { basename } from '../system/path';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { pad } from '../system/string';
import { ActiveEditorCommand, getCommandUri } from './base';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithRevisionFromCommandArgs {
@ -44,7 +45,7 @@ export class DiffWithRevisionFromCommand extends ActiveEditorCommand {
let ref;
let sha;
if (args?.stash) {
const title = `Open Changes with Stash${Strings.pad(GlyphChars.Dot, 2, 2)}`;
const title = `Open Changes with Stash${pad(GlyphChars.Dot, 2, 2)}`;
const pick = await StashPicker.show(
this.container.git.getStash(gitUri.repoPath),
`${title}${gitUri.getFormattedFileName({ truncateTo: quickPickTitleMaxChars - title.length })}`,
@ -60,7 +61,7 @@ export class DiffWithRevisionFromCommand extends ActiveEditorCommand {
ref = pick.ref;
sha = ref;
} else {
const title = `Open Changes with Branch or Tag${Strings.pad(GlyphChars.Dot, 2, 2)}`;
const title = `Open Changes with Branch or Tag${pad(GlyphChars.Dot, 2, 2)}`;
const pick = await ReferencePicker.show(
gitUri.repoPath,
`${title}${gitUri.getFormattedFileName({ truncateTo: quickPickTitleMaxChars - title.length })}`,

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

@ -5,8 +5,8 @@ import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithWorkingCommandArgs {

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

@ -7,10 +7,10 @@ import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { RepositoryPicker } from '../quickpicks';
import { Arrays } from '../system';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { filterMap } from '../system/array';
import { command } from '../system/command';
import {
command,
Command,
CommandContext,
isCommandContextViewNodeHasFileCommit,
@ -74,7 +74,7 @@ export class ExternalDiffCommand extends Command {
staged: (r as ScmResource).resourceGroupType === ScmResourceGroupType.Index,
}));
} else if (context.type === 'scm-groups') {
args.files = Arrays.filterMap(context.scmResourceGroups[0].resourceStates, r =>
args.files = filterMap(context.scmResourceGroups[0].resourceStates, r =>
this.isModified(r)
? {
uri: r.resourceUri,

+ 5
- 4
src/commands/git/branch.ts View File

@ -1,8 +1,9 @@
import { QuickInputButtons } from 'vscode';
import { Container } from '../../container';
import type { Container } from '../../container';
import { GitBranchReference, GitReference, Repository } from '../../git/models';
import { FlagsQuickPickItem, QuickPickItemOfT } from '../../quickpicks';
import { Strings } from '../../system';
import { QuickPickItemOfT } from '../../quickpicks/items/common';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
appendReposToTitle,
@ -388,7 +389,7 @@ export class BranchGitCommand extends QuickCommand {
}
context.title = getTitle(
Strings.pluralize('Branch', state.references.length, { only: true, plural: 'Branches' }),
pluralize('Branch', state.references.length, { only: true, plural: 'Branches' }),
state.subcommand,
);

+ 1
- 1
src/commands/git/cherry-pick.ts View File

@ -1,6 +1,6 @@
import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/models';
import { FlagsQuickPickItem } from '../../quickpicks';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
appendReposToTitle,

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

@ -1,6 +1,6 @@
import { CoreCommands } from '../../constants';
import { Container } from '../../container';
import { GitContributor, Repository } from '../../git/models';
import type { Container } from '../../container';
import type { GitContributor, Repository } from '../../git/models';
import { executeCoreCommand } from '../../system/command';
import { normalizePath } from '../../system/path';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 1
- 1
src/commands/git/fetch.ts View File

@ -1,7 +1,7 @@
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitBranchReference, GitReference, Repository } from '../../git/models';
import { FlagsQuickPickItem } from '../../quickpicks';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { isStringArray } from '../../system/array';
import { fromNow } from '../../system/date';
import { pad } from '../../system/string';

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

@ -1,10 +1,10 @@
import { GlyphChars, quickPickTitleMaxChars } from '../../constants';
import { Container } from '../../container';
import { GitCommit, GitLog, GitReference, Repository } from '../../git/models';
import { Strings } from '../../system';
import { formatPath } from '../../system/formatPath';
import { pad } from '../../system/string';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitCommandsCommand } from '../gitCommands';
import { getSteps } from '../gitCommands.utils';
import {
PartialStepState,
pickBranchOrTagStep,
@ -146,13 +146,13 @@ export class LogGitCommand extends QuickCommand {
context.selectedBranchOrTag = state.reference;
}
context.title = `${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${GitReference.toString(
context.title = `${this.title}${pad(GlyphChars.Dot, 2, 2)}${GitReference.toString(
context.selectedBranchOrTag,
{ icon: false },
)}`;
if (state.fileName) {
context.title += `${Strings.pad(GlyphChars.Dot, 2, 2)}${formatPath(state.fileName, {
context.title += `${pad(GlyphChars.Dot, 2, 2)}${formatPath(state.fileName, {
fileOnly: true,
truncateTo: quickPickTitleMaxChars - context.title.length - 3,
})}`;
@ -191,7 +191,7 @@ export class LogGitCommand extends QuickCommand {
state.reference = await this.container.git.getCommit(state.repo.path, state.reference.ref);
}
const result = yield* GitCommandsCommand.getSteps(
const result = yield* getSteps(
this.container,
{
command: 'show',

+ 8
- 7
src/commands/git/merge.ts View File

@ -1,7 +1,8 @@
import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
appendReposToTitle,
@ -225,28 +226,28 @@ export class MergeGitCommand extends QuickCommand {
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
label: this.title,
detail: `Will merge ${Strings.pluralize('commit', count)} from ${GitReference.toString(
detail: `Will merge ${pluralize('commit', count)} from ${GitReference.toString(
state.reference,
)} into ${GitReference.toString(context.destination)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--ff-only'], {
label: `Fast-forward ${this.title}`,
description: '--ff-only',
detail: `Will fast-forward merge ${Strings.pluralize('commit', count)} from ${GitReference.toString(
detail: `Will fast-forward merge ${pluralize('commit', count)} from ${GitReference.toString(
state.reference,
)} into ${GitReference.toString(context.destination)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--squash'], {
label: `Squash ${this.title}`,
description: '--squash',
detail: `Will squash ${Strings.pluralize('commit', count)} from ${GitReference.toString(
detail: `Will squash ${pluralize('commit', count)} from ${GitReference.toString(
state.reference,
)} into one when merging into ${GitReference.toString(context.destination)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--no-ff'], {
label: `${this.title} without Fast-Forwarding`,
description: '--no-ff',
detail: `Will create a merge commit when merging ${Strings.pluralize(
detail: `Will create a merge commit when merging ${pluralize(
'commit',
count,
)} from ${GitReference.toString(state.reference)} into ${GitReference.toString(
@ -256,7 +257,7 @@ export class MergeGitCommand extends QuickCommand {
FlagsQuickPickItem.create<Flags>(state.flags, ['--no-ff', '--no-commit'], {
label: `${this.title} without Fast-Forwarding or Committing`,
description: '--no-ff --no-commit',
detail: `Will merge ${Strings.pluralize('commit', count)} from ${GitReference.toString(
detail: `Will merge ${pluralize('commit', count)} from ${GitReference.toString(
state.reference,
)} into ${GitReference.toString(context.destination)} without Committing`,
}),

+ 2
- 1
src/commands/git/pull.ts View File

@ -1,7 +1,8 @@
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { isStringArray } from '../../system/array';
import { fromNow } from '../../system/date';
import { pad, pluralize } from '../../system/string';

+ 2
- 1
src/commands/git/push.ts View File

@ -2,7 +2,8 @@ import { configuration } from '../../configuration';
import { CoreGitConfiguration, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { isStringArray } from '../../system/array';
import { fromNow } from '../../system/date';
import { pad, pluralize } from '../../system/string';

+ 5
- 6
src/commands/git/rebase.ts View File

@ -1,8 +1,9 @@
import { env } from 'vscode';
import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
appendReposToTitle,
@ -252,7 +253,7 @@ export class RebaseGitCommand extends QuickCommand {
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
label: this.title,
detail: `Will update ${GitReference.toString(context.destination)} by applying ${Strings.pluralize(
detail: `Will update ${GitReference.toString(context.destination)} by applying ${pluralize(
'commit',
count,
)} on top of ${GitReference.toString(state.reference)}`,
@ -262,9 +263,7 @@ export class RebaseGitCommand extends QuickCommand {
description: '--interactive',
detail: `Will interactively update ${GitReference.toString(
context.destination,
)} by applying ${Strings.pluralize('commit', count)} on top of ${GitReference.toString(
state.reference,
)}`,
)} by applying ${pluralize('commit', count)} on top of ${GitReference.toString(state.reference)}`,
}),
],
);

+ 1
- 1
src/commands/git/reset.ts View File

@ -1,6 +1,6 @@
import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevisionReference, Repository } from '../../git/models';
import { FlagsQuickPickItem } from '../../quickpicks';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
appendReposToTitle,

+ 1
- 1
src/commands/git/revert.ts View File

@ -1,6 +1,6 @@
import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevisionReference, Repository } from '../../git/models';
import { FlagsQuickPickItem } from '../../quickpicks';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
appendReposToTitle,

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

@ -2,11 +2,11 @@ import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitCommit, GitLog, Repository } from '../../git/models';
import { searchOperators, SearchOperators, SearchPattern } from '../../git/search';
import { ActionQuickPickItem, QuickPickItemOfT } from '../../quickpicks';
import { Strings } from '../../system';
import { ActionQuickPickItem, QuickPickItemOfT } from '../../quickpicks/items/common';
import { pluralize } from '../../system/string';
import { SearchResultsNode } from '../../views/nodes';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitCommandsCommand } from '../gitCommands';
import { getSteps } from '../gitCommands.utils';
import {
appendReposToTitle,
PartialStepState,
@ -191,7 +191,7 @@ export class SearchGitCommand extends QuickCommand {
placeholder: (context, log) =>
log == null
? `No results for ${state.pattern}`
: `${Strings.pluralize('result', log.count, {
: `${pluralize('result', log.count, {
format: c => (log.hasMore ? `${c}+` : undefined),
})} for ${state.pattern}`,
picked: context.commit?.ref,
@ -238,7 +238,7 @@ export class SearchGitCommand extends QuickCommand {
context.commit = result;
}
const result = yield* GitCommandsCommand.getSteps(
const result = yield* getSteps(
this.container,
{
command: 'show',

+ 3
- 1
src/commands/git/show.ts View File

@ -1,6 +1,8 @@
import { Container } from '../../container';
import { GitCommit, GitRevisionReference, GitStashCommit, Repository } from '../../git/models';
import { CommandQuickPickItem, CommitFilesQuickPickItem, GitCommandQuickPickItem } from '../../quickpicks';
import { CommitFilesQuickPickItem } from '../../quickpicks/items/commits';
import { CommandQuickPickItem } from '../../quickpicks/items/common';
import { GitCommandQuickPickItem } from '../../quickpicks/items/gitCommands';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
PartialStepState,

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

@ -5,12 +5,13 @@ import { StashApplyError, StashApplyErrorReason } from '../../git/errors';
import { GitReference, GitStashCommit, GitStashReference, Repository } from '../../git/models';
import { Logger } from '../../logger';
import { Messages } from '../../messages';
import { FlagsQuickPickItem, QuickPickItemOfT } from '../../quickpicks';
import { Strings } from '../../system';
import { QuickPickItemOfT } from '../../quickpicks/items/common';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { formatPath } from '../../system/formatPath';
import { pad } from '../../system/string';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitCommandsCommand } from '../gitCommands';
import { GitActions } from '../gitCommands.actions';
import { getSteps } from '../gitCommands.utils';
import {
appendReposToTitle,
AsyncStepResultGenerator,
@ -432,7 +433,7 @@ export class StashGitCommand extends QuickCommand {
state.reference = result;
}
const result = yield* GitCommandsCommand.getSteps(
const result = yield* getSteps(
this.container,
{
command: 'show',
@ -504,7 +505,7 @@ export class StashGitCommand extends QuickCommand {
state,
context,
state.uris != null
? `${Strings.pad(GlyphChars.Dot, 2, 2)}${
? `${pad(GlyphChars.Dot, 2, 2)}${
state.uris.length === 1
? formatPath(state.uris[0], { fileOnly: true })
: `${state.uris.length} files`

+ 4
- 3
src/commands/git/status.ts View File

@ -1,8 +1,9 @@
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitReference, GitStatus, Repository } from '../../git/models';
import { CommandQuickPickItem, GitCommandQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { CommandQuickPickItem } from '../../quickpicks/items/common';
import { GitCommandQuickPickItem } from '../../quickpicks/items/gitCommands';
import { pad } from '../../system/string';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
PartialStepState,
@ -88,7 +89,7 @@ export class StatusGitCommand extends QuickCommand {
context.status = (await state.repo.getStatus())!;
if (context.status == null) return;
context.title = `${this.title}${Strings.pad(GlyphChars.Dot, 2, 2)}${GitReference.toString(
context.title = `${this.title}${pad(GlyphChars.Dot, 2, 2)}${GitReference.toString(
GitReference.create(context.status.branch, state.repo.path, {
refType: 'branch',
name: context.status.branch,

+ 2
- 7
src/commands/git/switch.ts View File

@ -2,7 +2,7 @@ import { ProgressLocation, QuickPickItem, window } from 'vscode';
import { BranchSorting } from '../../config';
import { Container } from '../../container';
import { GitReference, Repository } from '../../git/models';
import { Arrays } from '../../system';
import { isStringArray } from '../../system/array';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
appendReposToTitle,
@ -104,12 +104,7 @@ export class SwitchGitCommand extends QuickCommand {
while (this.canStepsContinue(state)) {
context.title = this.title;
if (
state.counter < 1 ||
state.repos == null ||
state.repos.length === 0 ||
Arrays.isStringArray(state.repos)
) {
if (state.counter < 1 || state.repos == null || state.repos.length === 0 || isStringArray(state.repos)) {
skippedStepOne = false;
if (context.repos.length === 1) {
skippedStepOne = true;

+ 4
- 6
src/commands/git/tag.ts View File

@ -1,8 +1,9 @@
import { QuickInputButtons, QuickPickItem } from 'vscode';
import { Container } from '../../container';
import { GitReference, GitTagReference, Repository } from '../../git/models';
import { FlagsQuickPickItem, QuickPickItemOfT } from '../../quickpicks';
import { Strings } from '../../system';
import { QuickPickItemOfT } from '../../quickpicks/items/common';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {
appendReposToTitle,
@ -351,10 +352,7 @@ export class TagGitCommand extends QuickCommand {
state.references = result;
}
context.title = getTitle(
Strings.pluralize('Tag', state.references.length, { only: true }),
state.subcommand,
);
context.title = getTitle(pluralize('Tag', state.references.length, { only: true }), state.subcommand);
const result = yield* this.deleteCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;

+ 1
- 1
src/commands/gitCommands.actions.ts View File

@ -23,7 +23,7 @@ import {
GitTagReference,
Repository,
} from '../git/models';
import { RepositoryPicker } from '../quickpicks';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { executeCommand, executeEditorCommand } from '../system/command';
import { findOrOpenEditor, findOrOpenEditors } from '../system/utils';
import { ViewsWithRepositoryFolders } from '../views/viewBase';

+ 22
- 121
src/commands/gitCommands.ts View File

@ -1,37 +1,37 @@
import { Disposable, InputBox, QuickInputButton, QuickInputButtons, QuickPick, QuickPickItem, window } from 'vscode';
import { configuration, GitCommandSorting } from '../configuration';
import { configuration } from '../configuration';
import { Commands } from '../constants';
import type { Container } from '../container';
import { KeyMapping } from '../keyboard';
import { Directive, DirectiveQuickPickItem } from '../quickpicks';
import { Usage, WorkspaceState } from '../storage';
import { Directive, DirectiveQuickPickItem } from '../quickpicks/items/directive';
import { command } from '../system/command';
import { log } from '../system/decorators/log';
import { isPromise } from '../system/promise';
import { command, Command, CommandContext } from './base';
import { BranchGitCommand, BranchGitCommandArgs } from './git/branch';
import { CherryPickGitCommand, CherryPickGitCommandArgs } from './git/cherry-pick';
import { CoAuthorsGitCommand, CoAuthorsGitCommandArgs } from './git/coauthors';
import { FetchGitCommand, FetchGitCommandArgs } from './git/fetch';
import { LogGitCommand, LogGitCommandArgs } from './git/log';
import { MergeGitCommand, MergeGitCommandArgs } from './git/merge';
import { PullGitCommand, PullGitCommandArgs } from './git/pull';
import { PushGitCommand, PushGitCommandArgs } from './git/push';
import { RebaseGitCommand, RebaseGitCommandArgs } from './git/rebase';
import { ResetGitCommand, ResetGitCommandArgs } from './git/reset';
import { RevertGitCommand, RevertGitCommandArgs } from './git/revert';
import { SearchGitCommand, SearchGitCommandArgs } from './git/search';
import { ShowGitCommand, ShowGitCommandArgs } from './git/show';
import { StashGitCommand, StashGitCommandArgs } from './git/stash';
import { StatusGitCommand, StatusGitCommandArgs } from './git/status';
import { SwitchGitCommand, SwitchGitCommandArgs } from './git/switch';
import { TagGitCommand, TagGitCommandArgs } from './git/tag';
import { Command, CommandContext } from './base';
import type { BranchGitCommandArgs } from './git/branch';
import type { CherryPickGitCommandArgs } from './git/cherry-pick';
import type { CoAuthorsGitCommandArgs } from './git/coauthors';
import type { FetchGitCommandArgs } from './git/fetch';
import type { LogGitCommandArgs } from './git/log';
import type { MergeGitCommandArgs } from './git/merge';
import type { PullGitCommandArgs } from './git/pull';
import type { PushGitCommandArgs } from './git/push';
import type { RebaseGitCommandArgs } from './git/rebase';
import type { ResetGitCommandArgs } from './git/reset';
import type { RevertGitCommandArgs } from './git/revert';
import type { SearchGitCommandArgs } from './git/search';
import type { ShowGitCommandArgs } from './git/show';
import type { StashGitCommandArgs } from './git/stash';
import type { StatusGitCommandArgs } from './git/status';
import type { SwitchGitCommandArgs } from './git/switch';
import type { TagGitCommandArgs } from './git/tag';
import { PickCommandStep } from './gitCommands.utils';
import {
isQuickInputStep,
isQuickPickStep,
QuickCommand,
QuickInputStep,
QuickPickStep,
StepGenerator,
StepSelection,
} from './quickCommand';
import { QuickCommandButtons, ToggleQuickInputButton } from './quickCommand.buttons';
@ -58,23 +58,8 @@ export type GitCommandsCommandArgs =
| SwitchGitCommandArgs
| TagGitCommandArgs;
function* nullSteps(): StepGenerator {
/* noop */
}
@command()
export class GitCommandsCommand extends Command {
static getSteps(container: Container, args: GitCommandsCommandArgs, pickedVia: 'menu' | 'command'): StepGenerator {
const commandsStep = new PickCommandStep(container, args);
const command = commandsStep.find(args.command);
if (command == null) return nullSteps();
commandsStep.setCommand(command, pickedVia);
return command.executeSteps();
}
private startedWith: 'menu' | 'command' = 'menu';
constructor(private readonly container: Container) {
@ -736,87 +721,3 @@ export class GitCommandsCommand extends Command {
}
}
}
class PickCommandStep implements QuickPickStep {
readonly buttons = [];
private readonly hiddenItems: QuickCommand[];
ignoreFocusOut = false;
readonly items: QuickCommand[];
readonly matchOnDescription = true;
readonly placeholder = 'Choose a git command';
readonly title = 'GitLens';
constructor(private readonly container: Container, args?: GitCommandsCommandArgs) {
this.items = [
new BranchGitCommand(container, args?.command === 'branch' ? args : undefined),
new CherryPickGitCommand(container, args?.command === 'cherry-pick' ? args : undefined),
new CoAuthorsGitCommand(container, args?.command === 'co-authors' ? args : undefined),
new FetchGitCommand(container, args?.command === 'fetch' ? args : undefined),
new LogGitCommand(container, args?.command === 'log' ? args : undefined),
new MergeGitCommand(container, args?.command === 'merge' ? args : undefined),
new PullGitCommand(container, args?.command === 'pull' ? args : undefined),
new PushGitCommand(container, args?.command === 'push' ? args : undefined),
new RebaseGitCommand(container, args?.command === 'rebase' ? args : undefined),
new ResetGitCommand(container, args?.command === 'reset' ? args : undefined),
new RevertGitCommand(container, args?.command === 'revert' ? args : undefined),
new SearchGitCommand(container, args?.command === 'search' || args?.command === 'grep' ? args : undefined),
new ShowGitCommand(container, args?.command === 'show' ? args : undefined),
new StashGitCommand(container, args?.command === 'stash' ? args : undefined),
new StatusGitCommand(container, args?.command === 'status' ? args : undefined),
new SwitchGitCommand(
container,
args?.command === 'switch' || args?.command === 'checkout' ? args : undefined,
),
new TagGitCommand(container, args?.command === 'tag' ? args : undefined),
];
if (this.container.config.gitCommands.sortBy === GitCommandSorting.Usage) {
const usage = this.container.storage.getWorkspace<Usage>(WorkspaceState.GitCommandPaletteUsage);
if (usage != null) {
this.items.sort((a, b) => (usage[b.key] ?? 0) - (usage[a.key] ?? 0));
}
}
this.hiddenItems = [];
}
private _command: QuickCommand | undefined;
get command(): QuickCommand | undefined {
return this._command;
}
find(commandName: string, fuzzy: boolean = false) {
if (fuzzy) {
const cmd = commandName.toLowerCase();
return this.items.find(c => c.isFuzzyMatch(cmd)) ?? this.hiddenItems.find(c => c.isFuzzyMatch(cmd));
}
return this.items.find(c => c.isMatch(commandName)) ?? this.hiddenItems.find(c => c.isMatch(commandName));
}
setCommand(command: QuickCommand | undefined, via: 'menu' | 'command'): void {
if (this._command != null) {
this._command.picked = false;
}
if (command != null) {
command.picked = true;
command.pickedVia = via;
}
this._command = command;
if (command != null) {
void this.updateCommandUsage(command.key, Date.now());
}
}
private async updateCommandUsage(id: string, timestamp: number) {
let usage = this.container.storage.getWorkspace<Usage>(WorkspaceState.GitCommandPaletteUsage);
if (usage === undefined) {
usage = Object.create(null) as Usage;
}
usage[id] = timestamp;
await this.container.storage.storeWorkspace(WorkspaceState.GitCommandPaletteUsage, usage);
}
}

+ 125
- 0
src/commands/gitCommands.utils.ts View File

@ -0,0 +1,125 @@
import { GitCommandSorting } from '../config';
import type { Container } from '../container';
import { Usage, WorkspaceState } from '../storage';
import { BranchGitCommand } from './git/branch';
import { CherryPickGitCommand } from './git/cherry-pick';
import { CoAuthorsGitCommand } from './git/coauthors';
import { FetchGitCommand } from './git/fetch';
import { LogGitCommand } from './git/log';
import { MergeGitCommand } from './git/merge';
import { PullGitCommand } from './git/pull';
import { PushGitCommand } from './git/push';
import { RebaseGitCommand } from './git/rebase';
import { ResetGitCommand } from './git/reset';
import { RevertGitCommand } from './git/revert';
import { SearchGitCommand } from './git/search';
import { ShowGitCommand } from './git/show';
import { StashGitCommand } from './git/stash';
import { StatusGitCommand } from './git/status';
import { SwitchGitCommand } from './git/switch';
import { TagGitCommand } from './git/tag';
import type { GitCommandsCommandArgs } from './gitCommands';
import type { QuickCommand, QuickPickStep, StepGenerator } from './quickCommand';
function* nullSteps(): StepGenerator {
/* noop */
}
export function getSteps(
container: Container,
args: GitCommandsCommandArgs,
pickedVia: 'menu' | 'command',
): StepGenerator {
const commandsStep = new PickCommandStep(container, args);
const command = commandsStep.find(args.command);
if (command == null) return nullSteps();
commandsStep.setCommand(command, pickedVia);
return command.executeSteps();
}
export class PickCommandStep implements QuickPickStep {
readonly buttons = [];
private readonly hiddenItems: QuickCommand[];
ignoreFocusOut = false;
readonly items: QuickCommand[];
readonly matchOnDescription = true;
readonly placeholder = 'Choose a git command';
readonly title = 'GitLens';
constructor(private readonly container: Container, args?: GitCommandsCommandArgs) {
this.items = [
new BranchGitCommand(container, args?.command === 'branch' ? args : undefined),
new CherryPickGitCommand(container, args?.command === 'cherry-pick' ? args : undefined),
new CoAuthorsGitCommand(container, args?.command === 'co-authors' ? args : undefined),
new FetchGitCommand(container, args?.command === 'fetch' ? args : undefined),
new LogGitCommand(container, args?.command === 'log' ? args : undefined),
new MergeGitCommand(container, args?.command === 'merge' ? args : undefined),
new PullGitCommand(container, args?.command === 'pull' ? args : undefined),
new PushGitCommand(container, args?.command === 'push' ? args : undefined),
new RebaseGitCommand(container, args?.command === 'rebase' ? args : undefined),
new ResetGitCommand(container, args?.command === 'reset' ? args : undefined),
new RevertGitCommand(container, args?.command === 'revert' ? args : undefined),
new SearchGitCommand(container, args?.command === 'search' || args?.command === 'grep' ? args : undefined),
new ShowGitCommand(container, args?.command === 'show' ? args : undefined),
new StashGitCommand(container, args?.command === 'stash' ? args : undefined),
new StatusGitCommand(container, args?.command === 'status' ? args : undefined),
new SwitchGitCommand(
container,
args?.command === 'switch' || args?.command === 'checkout' ? args : undefined,
),
new TagGitCommand(container, args?.command === 'tag' ? args : undefined),
];
if (this.container.config.gitCommands.sortBy === GitCommandSorting.Usage) {
const usage = this.container.storage.getWorkspace<Usage>(WorkspaceState.GitCommandPaletteUsage);
if (usage != null) {
this.items.sort((a, b) => (usage[b.key] ?? 0) - (usage[a.key] ?? 0));
}
}
this.hiddenItems = [];
}
private _command: QuickCommand | undefined;
get command(): QuickCommand | undefined {
return this._command;
}
find(commandName: string, fuzzy: boolean = false) {
if (fuzzy) {
const cmd = commandName.toLowerCase();
return this.items.find(c => c.isFuzzyMatch(cmd)) ?? this.hiddenItems.find(c => c.isFuzzyMatch(cmd));
}
return this.items.find(c => c.isMatch(commandName)) ?? this.hiddenItems.find(c => c.isMatch(commandName));
}
setCommand(command: QuickCommand | undefined, via: 'menu' | 'command'): void {
if (this._command != null) {
this._command.picked = false;
}
if (command != null) {
command.picked = true;
command.pickedVia = via;
}
this._command = command;
if (command != null) {
void this.updateCommandUsage(command.key, Date.now());
}
}
private async updateCommandUsage(id: string, timestamp: number) {
let usage = this.container.storage.getWorkspace<Usage>(WorkspaceState.GitCommandPaletteUsage);
if (usage === undefined) {
usage = Object.create(null) as Usage;
}
usage[id] = timestamp;
await this.container.storage.storeWorkspace(WorkspaceState.GitCommandPaletteUsage, usage);
}
}

+ 2
- 1
src/commands/inviteToLiveShare.ts View File

@ -1,6 +1,7 @@
import { Commands } from '../constants';
import type { Container } from '../container';
import { command, Command, CommandContext, isCommandContextViewNodeHasContributor } from './base';
import { command } from '../system/command';
import { Command, CommandContext, isCommandContextViewNodeHasContributor } from './base';
export interface InviteToLiveShareCommandArgs {
email?: string;

+ 2
- 1
src/commands/logging.ts View File

@ -1,7 +1,8 @@
import { configuration, OutputLevel } from '../configuration';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command, Command } from './base';
import { command } from '../system/command';
import { Command } from './base';
@command()
export class EnableDebugLoggingCommand extends Command {

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

@ -3,8 +3,8 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
import { OpenPullRequestOnRemoteCommandArgs } from './openPullRequestOnRemote';
@command()

+ 5
- 3
src/commands/openBranchOnRemote.ts View File

@ -4,9 +4,11 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { CommandQuickPickItem, ReferencePicker, ReferencesQuickPickIncludes, RepositoryPicker } from '../quickpicks';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, CommandContext, getCommandUri, isCommandContextViewNodeHasBranch } from './base';
import { CommandQuickPickItem } from '../quickpicks/items/common';
import { ReferencePicker, ReferencesQuickPickIncludes } from '../quickpicks/referencePicker';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, CommandContext, getCommandUri, isCommandContextViewNodeHasBranch } from './base';
import { OpenOnRemoteCommandArgs } from './openOnRemote';
export interface OpenBranchOnRemoteCommandArgs {

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

@ -4,9 +4,9 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { RepositoryPicker } from '../quickpicks';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, CommandContext, getCommandUri, isCommandContextViewNodeHasRemote } from './base';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, CommandContext, getCommandUri, isCommandContextViewNodeHasRemote } from './base';
import { OpenOnRemoteCommandArgs } from './openOnRemote';
export interface OpenBranchesOnRemoteCommandArgs {

+ 5
- 4
src/commands/openChangedFiles.ts View File

@ -3,10 +3,11 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { RepositoryPicker } from '../quickpicks';
import { Arrays } from '../system';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { filterMap } from '../system/array';
import { command } from '../system/command';
import { findOrOpenEditors } from '../system/utils';
import { Command, command } from './base';
import { Command } from './base';
export interface OpenChangedFilesCommandArgs {
uris?: Uri[];
@ -33,7 +34,7 @@ export class OpenChangedFilesCommand extends Command {
return;
}
args.uris = Arrays.filterMap(status.files, f => (f.status !== 'D' ? f.uri : undefined));
args.uris = filterMap(status.files, f => (f.status !== 'D' ? f.uri : undefined));
}
findOrOpenEditors(args.uris);

+ 1
- 2
src/commands/openCommitOnRemote.ts View File

@ -6,10 +6,9 @@ import { GitRevision } from '../git/models';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { executeCommand } from '../system/command';
import { command, executeCommand } from '../system/command';
import {
ActiveEditorCommand,
command,
CommandContext,
getCommandUri,
isCommandContextGitTimelineItem,

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

@ -3,9 +3,9 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { executeCommand } from '../system/command';
import { command, executeCommand } from '../system/command';
import { ResultsCommitsNode } from '../views/nodes';
import { Command, command, CommandContext } from './base';
import { Command, CommandContext } from './base';
import { OpenOnRemoteCommandArgs } from './openOnRemote';
export interface OpenComparisonOnRemoteCommandArgs {

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

@ -4,9 +4,11 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ReferencePicker, RepositoryPicker } from '../quickpicks';
import { ReferencePicker } from '../quickpicks/referencePicker';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command } from '../system/command';
import { CompareResultsNode } from '../views/nodes';
import { ActiveEditorCommand, command, CommandContext, getCommandUri, isCommandContextViewNodeHasRef } from './base';
import { ActiveEditorCommand, CommandContext, getCommandUri, isCommandContextViewNodeHasRef } from './base';
export interface OpenDirectoryCompareCommandArgs {
ref1?: string;

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

@ -6,9 +6,11 @@ import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, CommitPicker } from '../quickpicks';
import { Strings } from '../system';
import { ActiveEditorCommand, command, CommandContext, getCommandUri } from './base';
import { CommitPicker } from '../quickpicks/commitPicker';
import { CommandQuickPickItem } from '../quickpicks/items/common';
import { command } from '../system/command';
import { pad } from '../system/string';
import { ActiveEditorCommand, CommandContext, getCommandUri } from './base';
import { GitActions } from './gitCommands.actions';
import { OpenFileAtRevisionFromCommandArgs } from './openFileAtRevisionFrom';
@ -117,7 +119,7 @@ export class OpenFileAtRevisionCommand extends ActiveEditorCommand {
const title = `Open ${
args.annotationType === FileAnnotationType.Blame ? 'Blame' : 'File'
} at Revision${Strings.pad(GlyphChars.Dot, 2, 2)}`;
} at Revision${pad(GlyphChars.Dot, 2, 2)}`;
const pick = await CommitPicker.show(
log,
`${title}${gitUri.getFormattedFileName({

+ 7
- 5
src/commands/openFileAtRevisionFrom.ts View File

@ -5,9 +5,11 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { GitReference } from '../git/models';
import { Messages } from '../messages';
import { ReferencePicker, StashPicker } from '../quickpicks';
import { Strings } from '../system';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { StashPicker } from '../quickpicks/commitPicker';
import { ReferencePicker } from '../quickpicks/referencePicker';
import { command } from '../system/command';
import { pad } from '../system/string';
import { ActiveEditorCommand, getCommandUri } from './base';
import { GitActions } from './gitCommands.actions';
export interface OpenFileAtRevisionFromCommandArgs {
@ -44,7 +46,7 @@ export class OpenFileAtRevisionFromCommand extends ActiveEditorCommand {
if (args?.stash) {
const path = this.container.git.getRelativePath(gitUri, gitUri.repoPath);
const title = `Open Changes with Stash${Strings.pad(GlyphChars.Dot, 2, 2)}`;
const title = `Open Changes with Stash${pad(GlyphChars.Dot, 2, 2)}`;
const pick = await StashPicker.show(
this.container.git.getStash(gitUri.repoPath),
`${title}${gitUri.getFormattedFileName({ truncateTo: quickPickTitleMaxChars - title.length })}`,
@ -56,7 +58,7 @@ export class OpenFileAtRevisionFromCommand extends ActiveEditorCommand {
args.reference = pick;
} else {
const title = `Open File at Branch or Tag${Strings.pad(GlyphChars.Dot, 2, 2)}`;
const title = `Open File at Branch or Tag${pad(GlyphChars.Dot, 2, 2)}`;
const pick = await ReferencePicker.show(
gitUri.repoPath,
`${title}${gitUri.getFormattedFileName({ truncateTo: quickPickTitleMaxChars - title.length })}`,

+ 2
- 1
src/commands/openFileFromRemote.ts View File

@ -1,8 +1,9 @@
import { env, Range, Uri, window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command } from '../system/command';
import { openEditor } from '../system/utils';
import { command, Command } from './base';
import { Command } from './base';
@command()
export class OpenFileFromRemoteCommand extends Command {

+ 6
- 7
src/commands/openFileOnRemote.ts View File

@ -7,13 +7,12 @@ import { GitUri } from '../git/gitUri';
import { GitBranch, GitRevision } from '../git/models';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { ReferencePicker } from '../quickpicks';
import { Strings } from '../system';
import { executeCommand } from '../system/command';
import { ReferencePicker } from '../quickpicks/referencePicker';
import { command, executeCommand } from '../system/command';
import { pad, splitSingle } from '../system/string';
import { StatusFileNode } from '../views/nodes';
import {
ActiveEditorCommand,
command,
CommandContext,
getCommandUri,
isCommandContextViewNodeHasBranch,
@ -127,7 +126,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
let sha = args.sha ?? gitUri.sha;
if (args.branchOrTag == null && sha != null && !GitRevision.isSha(sha) && remotes.length !== 0) {
const [remoteName, branchName] = Strings.splitSingle(sha, '/');
const [remoteName, branchName] = splitSingle(sha, '/');
if (branchName != null) {
const remote = remotes.find(r => r.name === remoteName);
if (remote != null) {
@ -149,8 +148,8 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
const pick = await ReferencePicker.show(
gitUri.repoPath,
args.clipboard
? `Copy Remote File Url From${Strings.pad(GlyphChars.Dot, 2, 2)}${gitUri.relativePath}`
: `Open File on Remote From${Strings.pad(GlyphChars.Dot, 2, 2)}${gitUri.relativePath}`,
? `Copy Remote File Url From${pad(GlyphChars.Dot, 2, 2)}${gitUri.relativePath}`
: `Open File on Remote From${pad(GlyphChars.Dot, 2, 2)}${gitUri.relativePath}`,
`Choose a branch or tag to ${args.clipboard ? 'copy' : 'open'} the file revision from`,
{
allowEnteringRefs: true,

+ 2
- 1
src/commands/openIssueOnRemote.ts View File

@ -1,8 +1,9 @@
import { env, Uri } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command } from '../system/command';
import { AutolinkedItemNode } from '../views/nodes/autolinkedItemNode';
import { Command, command, CommandContext } from './base';
import { Command, CommandContext } from './base';
export interface OpenIssueOnRemoteCommandArgs {
clipboard?: boolean;

+ 20
- 17
src/commands/openOnRemote.ts View File

@ -4,9 +4,10 @@ import { GitRemote, GitRevision } from '../git/models';
import { RemoteProvider, RemoteResource, RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { RemoteProviderPicker } from '../quickpicks';
import { Strings } from '../system';
import { Command, command } from './base';
import { RemoteProviderPicker } from '../quickpicks/remoteProviderPicker';
import { command } from '../system/command';
import { pad, splitSingle } from '../system/string';
import { Command } from './base';
export type OpenOnRemoteCommandArgs =
| {
@ -47,7 +48,7 @@ export class OpenOnRemoteCommand extends Command {
try {
if (args.resource.type === RemoteResourceType.Branch) {
// Check to see if the remote is in the branch
const [remoteName, branchName] = Strings.splitSingle(args.resource.branch, '/');
const [remoteName, branchName] = splitSingle(args.resource.branch, '/');
if (branchName != null) {
const remote = remotes.find(r => r.name === remoteName);
if (remote != null) {
@ -85,9 +86,11 @@ export class OpenOnRemoteCommand extends Command {
switch (args.resource.type) {
case RemoteResourceType.Branch:
title = `${
args.clipboard ? `Copy ${provider} Branch Url` : `Open Branch on ${provider}`
}${Strings.pad(GlyphChars.Dot, 2, 2)}${args.resource.branch}`;
title = `${args.clipboard ? `Copy ${provider} Branch Url` : `Open Branch on ${provider}`}${pad(
GlyphChars.Dot,
2,
2,
)}${args.resource.branch}`;
break;
case RemoteResourceType.Branches:
@ -95,15 +98,17 @@ export class OpenOnRemoteCommand extends Command {
break;
case RemoteResourceType.Commit:
title = `${
args.clipboard ? `Copy ${provider} Commit Url` : `Open Commit on ${provider}`
}${Strings.pad(GlyphChars.Dot, 2, 2)}${GitRevision.shorten(args.resource.sha)}`;
title = `${args.clipboard ? `Copy ${provider} Commit Url` : `Open Commit on ${provider}`}${pad(
GlyphChars.Dot,
2,
2,
)}${GitRevision.shorten(args.resource.sha)}`;
break;
case RemoteResourceType.Comparison:
title = `${
args.clipboard ? `Copy ${provider} Comparison Url` : `Open Comparison on ${provider}`
}${Strings.pad(GlyphChars.Dot, 2, 2)}${GitRevision.createRange(
}${pad(GlyphChars.Dot, 2, 2)}${GitRevision.createRange(
args.resource.base,
args.resource.compare,
args.resource.notation ?? '...',
@ -118,7 +123,7 @@ export class OpenOnRemoteCommand extends Command {
args.clipboard
? `Copy ${provider} Create Pull Request Url`
: `Create Pull Request on ${provider}`
}${Strings.pad(GlyphChars.Dot, 2, 2)}${
}${pad(GlyphChars.Dot, 2, 2)}${
args.resource.base?.branch
? GitRevision.createRange(args.resource.base.branch, args.resource.compare.branch, '...')
: args.resource.compare.branch
@ -130,7 +135,7 @@ export class OpenOnRemoteCommand extends Command {
break;
case RemoteResourceType.File:
title = `${args.clipboard ? `Copy ${provider} File Url` : `Open File on ${provider}`}${Strings.pad(
title = `${args.clipboard ? `Copy ${provider} File Url` : `Open File on ${provider}`}${pad(
GlyphChars.Dot,
2,
2,
@ -142,13 +147,11 @@ export class OpenOnRemoteCommand extends Command {
break;
case RemoteResourceType.Revision: {
title = `${args.clipboard ? `Copy ${provider} File Url` : `Open File on ${provider}`}${Strings.pad(
title = `${args.clipboard ? `Copy ${provider} File Url` : `Open File on ${provider}`}${pad(
GlyphChars.Dot,
2,
2,
)}${GitRevision.shorten(args.resource.sha)}${Strings.pad(GlyphChars.Dot, 1, 1)}${
args.resource.fileName
}`;
)}${GitRevision.shorten(args.resource.sha)}${pad(GlyphChars.Dot, 1, 1)}${args.resource.fileName}`;
break;
}
}

+ 2
- 1
src/commands/openPullRequestOnRemote.ts View File

@ -1,8 +1,9 @@
import { env, Uri } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command } from '../system/command';
import { PullRequestNode } from '../views/nodes';
import { Command, command, CommandContext } from './base';
import { Command, CommandContext } from './base';
export interface OpenPullRequestOnRemoteCommandArgs {
clipboard?: boolean;

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

@ -4,9 +4,9 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { RepositoryPicker } from '../quickpicks';
import { executeCommand } from '../system/command';
import { ActiveEditorCommand, command, CommandContext, getCommandUri, isCommandContextViewNodeHasRemote } from './base';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, CommandContext, getCommandUri, isCommandContextViewNodeHasRemote } from './base';
import { OpenOnRemoteCommandArgs } from './openOnRemote';
export interface OpenRepoOnRemoteCommandArgs {

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

@ -6,7 +6,8 @@ import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { command } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
import { GitActions } from './gitCommands.actions';
export interface OpenRevisionFileCommandArgs {

+ 2
- 1
src/commands/openWorkingFile.ts View File

@ -5,8 +5,9 @@ import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { command } from '../system/command';
import { findOrOpenEditor } from '../system/utils';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { ActiveEditorCommand, getCommandUri } from './base';
export interface OpenWorkingFileCommandArgs {
uri?: Uri;

+ 13
- 11
src/commands/quickCommand.steps.ts View File

@ -25,8 +25,6 @@ import {
import { RemoteResourceType } from '../git/remotes/provider';
import { SearchPattern } from '../git/search';
import {
BranchQuickPickItem,
CommandQuickPickItem,
CommitApplyFileChangesCommandQuickPickItem,
CommitBrowseRepositoryFromHereCommandQuickPickItem,
CommitCompareWithHEADCommandQuickPickItem,
@ -47,21 +45,25 @@ import {
CommitOpenFilesCommandQuickPickItem,
CommitOpenRevisionCommandQuickPickItem,
CommitOpenRevisionsCommandQuickPickItem,
CommitQuickPickItem,
CommitRestoreFileChangesCommandQuickPickItem,
OpenChangedFilesCommandQuickPickItem,
} from '../quickpicks/items/commits';
import { CommandQuickPickItem, QuickPickSeparator } from '../quickpicks/items/common';
import { Directive, DirectiveQuickPickItem } from '../quickpicks/items/directive';
import {
BranchQuickPickItem,
CommitQuickPickItem,
ContributorQuickPickItem,
CopyRemoteResourceCommandQuickPickItem,
Directive,
DirectiveQuickPickItem,
GitCommandQuickPickItem,
OpenChangedFilesCommandQuickPickItem,
OpenRemoteResourceCommandQuickPickItem,
QuickPickSeparator,
ReferencesQuickPickItem,
RefQuickPickItem,
RepositoryQuickPickItem,
TagQuickPickItem,
} from '../quickpicks';
} from '../quickpicks/items/gitCommands';
import { ReferencesQuickPickItem } from '../quickpicks/referencePicker';
import {
CopyRemoteResourceCommandQuickPickItem,
OpenRemoteResourceCommandQuickPickItem,
} from '../quickpicks/remoteProviderPicker';
import { filterMap, intersection, isStringArray } from '../system/array';
import { formatPath } from '../system/formatPath';
import { map } from '../system/iterable';

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

@ -1,7 +1,7 @@
import { InputBox, QuickInputButton, QuickPick, QuickPickItem } from 'vscode';
import type { Container } from '../container';
import { Keys } from '../keyboard';
import { Directive, DirectiveQuickPickItem } from '../quickpicks';
import { Directive, DirectiveQuickPickItem } from '../quickpicks/items/directive';
export * from './quickCommand.buttons';
export * from './quickCommand.steps';

+ 2
- 1
src/commands/rebaseEditor.ts View File

@ -1,6 +1,7 @@
import { Commands } from '../constants';
import type { Container } from '../container';
import { command, Command } from './base';
import { command } from '../system/command';
import { Command } from './base';
@command()
export class DisableRebaseEditorCommand extends Command {

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

@ -1,7 +1,7 @@
import { Commands, CoreCommands } from '../constants';
import type { Container } from '../container';
import { executeCoreCommand } from '../system/command';
import { command, Command } from './base';
import { command, executeCoreCommand } from '../system/command';
import { Command } from './base';
@command()
export class RefreshHoverCommand extends Command {

+ 5
- 4
src/commands/remoteProviders.ts View File

@ -3,8 +3,9 @@ import type { Container } from '../container';
import { GitCommit, GitRemote, Repository } from '../git/models';
import { RichRemoteProvider } from '../git/remotes/provider';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { Iterables } from '../system';
import { command, Command, CommandContext, isCommandContextViewNodeHasRemote } from './base';
import { command } from '../system/command';
import { first } from '../system/iterable';
import { Command, CommandContext, isCommandContextViewNodeHasRemote } from './base';
export interface ConnectRemoteProviderCommandArgs {
remote: string;
@ -58,7 +59,7 @@ export class ConnectRemoteProviderCommand extends Command {
if (repos.size === 0) return false;
if (repos.size === 1) {
let repo;
[repo, remote] = Iterables.first(repos);
[repo, remote] = first(repos);
repoPath = repo.path;
} else {
const pick = await RepositoryPicker.show(
@ -149,7 +150,7 @@ export class DisconnectRemoteProviderCommand extends Command {
if (repos.size === 0) return undefined;
if (repos.size === 1) {
let repo;
[repo, remote] = Iterables.first(repos);
[repo, remote] = first(repos);
repoPath = repo.path;
} else {
const pick = await RepositoryPicker.show(

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

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

+ 2
- 1
src/commands/resetAvatarCache.ts View File

@ -1,7 +1,8 @@
import { resetAvatarCache } from '../avatars';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command, Command } from './base';
import { command } from '../system/command';
import { Command } from './base';
@command()
export class ResetAvatarCacheCommand extends Command {

+ 2
- 1
src/commands/resetSuppressedWarnings.ts View File

@ -2,7 +2,8 @@ import { ConfigurationTarget } from 'vscode';
import { configuration } from '../configuration';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command, Command } from './base';
import { command } from '../system/command';
import { Command } from './base';
@command()
export class ResetSuppressedWarningsCommand extends Command {

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

@ -2,8 +2,9 @@ import { executeGitCommand } from '../commands/gitCommands.actions';
import { Commands } from '../constants';
import type { Container } from '../container';
import { SearchPattern } from '../git/search';
import { command } from '../system/command';
import { SearchResultsNode } from '../views/nodes';
import { Command, command, CommandContext, isCommandContextViewNodeHasRepository } from './base';
import { Command, CommandContext, isCommandContextViewNodeHasRepository } from './base';
export interface SearchCommitsCommandArgs {
search?: Partial<SearchPattern>;

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

@ -2,8 +2,8 @@ import { window } from 'vscode';
import { viewsConfigKeys } from '../configuration';
import { Commands, CoreCommands } from '../constants';
import type { Container } from '../container';
import { executeCommand, executeCoreCommand } from '../system/command';
import { command, Command } from './base';
import { command, executeCommand, executeCoreCommand } from '../system/command';
import { Command } from './base';
enum ViewsLayout {
GitLens = 'gitlens',

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

@ -6,8 +6,9 @@ import { GitUri } from '../git/gitUri';
import { SearchPattern } from '../git/search';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';
import { ActiveEditorCommand, command, getCommandUri } from './base';
import { command } from '../system/command';
import { filterMap } from '../system/iterable';
import { ActiveEditorCommand, getCommandUri } from './base';
export interface ShowCommitsInViewCommandArgs {
refs?: string[];
@ -45,9 +46,7 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand {
return Messages.showFileNotUnderSourceControlWarningMessage('Unable to find commits');
}
args.refs = [
...Iterables.filterMap(blame.commits.values(), c => (c.isUncommitted ? undefined : c.ref)),
];
args.refs = [...filterMap(blame.commits.values(), c => (c.isUncommitted ? undefined : c.ref))];
} catch (ex) {
Logger.error(ex, 'ShowCommitsInViewCommand', 'getBlameForRange');
return Messages.showGenericErrorMessage('Unable to find commits');

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

@ -3,7 +3,8 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { command, Command, getLastCommand } from './base';
import { command } from '../system/command';
import { Command, getLastCommand } from './base';
@command()
export class ShowLastQuickPickCommand extends Command {

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

@ -3,7 +3,8 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { GitReference } from '../git/models';
import { ActiveEditorCachedCommand, command, CommandContext, getCommandUri } from './base';
import { command } from '../system/command';
import { ActiveEditorCachedCommand, CommandContext, getCommandUri } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface ShowQuickBranchHistoryCommandArgs {

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

@ -5,13 +5,8 @@ import { GitUri } from '../git/gitUri';
import { GitCommit, GitLog, GitStashCommit } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import {
ActiveEditorCachedCommand,
command,
CommandContext,
getCommandUri,
isCommandContextViewNodeHasCommit,
} from './base';
import { command } from '../system/command';
import { ActiveEditorCachedCommand, CommandContext, getCommandUri, isCommandContextViewNodeHasCommit } from './base';
import { executeGitCommand, GitActions } from './gitCommands.actions';
export interface ShowQuickCommitCommandArgs {

+ 2
- 7
src/commands/showQuickCommitFile.ts View File

@ -5,13 +5,8 @@ import { GitUri } from '../git/gitUri';
import { GitCommit, GitLog, GitStashCommit } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import {
ActiveEditorCachedCommand,
command,
CommandContext,
getCommandUri,
isCommandContextViewNodeHasCommit,
} from './base';
import { command } from '../system/command';
import { ActiveEditorCachedCommand, CommandContext, getCommandUri, isCommandContextViewNodeHasCommit } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface ShowQuickCommitFileCommandArgs {

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

@ -3,8 +3,9 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { GitBranch, GitLog, GitReference, GitTag } from '../git/models';
import { CommandQuickPickItem } from '../quickpicks';
import { ActiveEditorCachedCommand, command, CommandContext, getCommandUri } from './base';
import { CommandQuickPickItem } from '../quickpicks/items/common';
import { command } from '../system/command';
import { ActiveEditorCachedCommand, CommandContext, getCommandUri } from './base';
import { executeGitCommand } from './gitCommands.actions';
export interface ShowQuickFileHistoryCommandArgs {

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

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

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

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

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

@ -2,8 +2,8 @@ import { Commands, ContextKeys } from '../constants';
import type { Container } from '../container';
import { setContext } from '../context';
import { SyncedState } from '../storage';
import { executeCommand } from '../system/command';
import { command, Command, CommandContext } from './base';
import { command, executeCommand } from '../system/command';
import { Command, CommandContext } from './base';
@command()
export class ShowViewCommand extends Command {

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

@ -2,9 +2,9 @@ import { GitActions } from '../commands/gitCommands.actions';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitStashCommit, GitStashReference } from '../git/models';
import { CommandQuickPickItem } from '../quickpicks';
import { CommandQuickPickItem } from '../quickpicks/items/common';
import { command } from '../system/command';
import {
command,
Command,
CommandContext,
isCommandContextViewNodeHasCommit,

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

@ -5,9 +5,9 @@ import { GitActions } from '../commands/gitCommands.actions';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { command } from '../system/command';
import {
Command,
command,
CommandContext,
isCommandContextViewNodeHasFile,
isCommandContextViewNodeHasRepoPath,

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

@ -3,9 +3,10 @@ import { configuration } from '../configuration';
import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { ModePicker } from '../quickpicks';
import { log } from '../system';
import { command, Command } from './base';
import { ModePicker } from '../quickpicks/modePicker';
import { command } from '../system/command';
import { log } from '../system/decorators/log';
import { Command } from './base';
@command()
export class SwitchModeCommand extends Command {

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

@ -1,6 +1,7 @@
import { Commands } from '../constants';
import type { Container } from '../container';
import { command, Command } from './base';
import { command } from '../system/command';
import { Command } from './base';
@command()
export class ToggleCodeLensCommand extends Command {

+ 2
- 1
src/commands/toggleFileAnnotations.ts View File

@ -7,8 +7,9 @@ import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { command } from '../system/command';
import { isTextEditor } from '../system/utils';
import { ActiveEditorCommand, command, EditorCommand } from './base';
import { ActiveEditorCommand, EditorCommand } from './base';
@command()
export class ClearFileAnnotationsCommand extends EditorCommand {

+ 2
- 1
src/commands/toggleLineBlame.ts View File

@ -2,7 +2,8 @@ import { TextEditor, Uri, window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { ActiveEditorCommand, command } from './base';
import { command } from '../system/command';
import { ActiveEditorCommand } from './base';
@command()
export class ToggleLineBlameCommand extends ActiveEditorCommand {

+ 21
- 0
src/constants.ts View File

@ -1,3 +1,24 @@
declare global {
export type PartialDeep<T> = T extends Record<string, unknown> ? { [K in keyof T]?: PartialDeep<T[K]> } : T;
export type PickPartialDeep<T, K extends keyof T> = Omit<Partial<T>, K> & { [P in K]?: Partial<T[P]> };
export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
export type PickMutable<T, K extends keyof T> = Omit<T, K> & { -readonly [P in K]: T[P] };
export type ExcludeSome<T, K extends keyof T, R> = Omit<T, K> & { [P in K]-?: Exclude<T[P], R> };
export type ExtractAll<T, U> = { [K in keyof T]: T[K] extends U ? T[K] : never };
export type ExtractSome<T, K extends keyof T, R> = Omit<T, K> & { [P in K]-?: Extract<T[P], R> };
export type RequireSome<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: T[P] };
export type AllNonNullable<T> = { [P in keyof T]-?: NonNullable<T[P]> };
export type SomeNonNullable<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> };
export type NarrowRepo<T extends { repo?: unknown }> = ExcludeSome<T, 'repo', string | undefined>;
export type NarrowRepos<T extends { repos?: unknown }> = ExcludeSome<T, 'repos', string | string[] | undefined>;
}
export const quickPickTitleMaxChars = 80;
export const ImageMimetypes: Record<string, string> = {
'.png': 'image/png',

+ 1
- 2
src/extension.ts View File

@ -3,7 +3,6 @@ import { isWeb } from '@env/platform';
import { Api } from './api/api';
import type { CreatePullRequestActionContext, GitLensApi, OpenPullRequestActionContext } from './api/gitlens';
import type { CreatePullRequestOnRemoteCommandArgs, OpenPullRequestOnRemoteCommandArgs } from './commands';
import { registerCommands } from './commands/base';
import { configuration, Configuration, OutputLevel } from './configuration';
import { Commands, ContextKeys } from './constants';
import { Container } from './container';
@ -14,7 +13,7 @@ import { Logger, LogLevel } from './logger';
import { Messages } from './messages';
import { registerPartnerActionRunners } from './partners';
import { GlobalState, SyncedState } from './storage';
import { executeCommand } from './system/command';
import { executeCommand, registerCommands } from './system/command';
import { once } from './system/event';
import { Stopwatch } from './system/stopwatch';
import { compare } from './system/version';

+ 14
- 2
src/git/formatters/commitFormatter.ts View File

@ -1,5 +1,10 @@
import { Uri } from 'vscode';
import type { HoverCommandsActionContext, OpenPullRequestActionContext } from '../../api/gitlens';
import type {
Action,
ActionContext,
HoverCommandsActionContext,
OpenPullRequestActionContext,
} from '../../api/gitlens';
import { getPresenceDataUri } from '../../avatars';
import {
ConnectRemoteProviderCommand,
@ -9,11 +14,11 @@ import {
ShowQuickCommitCommand,
ShowQuickCommitFileCommand,
} from '../../commands';
import { Command } from '../../commands/base';
import { DateStyle, FileAnnotationType } from '../../configuration';
import { Commands, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { emojify } from '../../emojis';
import { getMarkdownActionCommand } from '../../system/command';
import { join, map } from '../../system/iterable';
import { PromiseCancelledError } from '../../system/promise';
import { escapeMarkdown, getSuperscript, TokenOptions } from '../../system/string';
@ -662,3 +667,10 @@ export class CommitFormatter extends Formatter {
return super.has<CommitFormatOptions>(template, ...tokens);
}
}
function getMarkdownActionCommand<T extends ActionContext>(action: Action<T>, args: Omit<T, 'type'>): string {
return Command.getMarkdownCommandArgsCore(`${Commands.ActionPrefix}${action}`, {
...args,
type: action,
});
}

+ 25
- 18
src/git/formatters/formatter.ts View File

@ -1,10 +1,17 @@
import { Strings } from '../../system';
const emptyStr = '';
import {
getTokensFromTemplate,
getWidth,
interpolate,
interpolateAsync,
padLeft,
padRight,
TokenOptions,
truncate,
} from '../../system/string';
export interface FormatOptions {
dateFormat?: string | null;
tokenOptions?: Record<string, Strings.TokenOptions | undefined>;
tokenOptions?: Record<string, TokenOptions | undefined>;
}
type Constructor<T = Record<string, unknown>> = new (...args: any[]) => T;
@ -46,7 +53,7 @@ export abstract class Formatter
private collapsableWhitespace: number = 0;
protected _padOrTruncate(s: string, options: Strings.TokenOptions | undefined) {
protected _padOrTruncate(s: string, options: TokenOptions | undefined) {
if (s == null || s.length === 0) return s;
// NOTE: the collapsable whitespace logic relies on the javascript template evaluation to be left to right
@ -67,7 +74,7 @@ export abstract class Formatter
max += this.collapsableWhitespace;
this.collapsableWhitespace = 0;
const width = Strings.getWidth(s);
const width = getWidth(s);
const diff = max - width;
if (diff > 0) {
if (options.collapseWhitespace) {
@ -75,20 +82,20 @@ export abstract class Formatter
}
if (options.padDirection === 'left') {
s = Strings.padLeft(s, max, undefined, width);
s = padLeft(s, max, undefined, width);
} else {
if (options.collapseWhitespace) {
max -= diff;
}
s = Strings.padRight(s, max, undefined, width);
s = padRight(s, max, undefined, width);
}
} else if (diff < 0) {
s = Strings.truncate(s, max, undefined, width);
s = truncate(s, max, undefined, width);
}
}
if (options.prefix || options.suffix) {
s = `${options.prefix ?? emptyStr}${s}${options.suffix ?? emptyStr}`;
s = `${options.prefix ?? ''}${s}${options.suffix ?? ''}`;
}
return s;
@ -104,7 +111,7 @@ export abstract class Formatter
): string {
// Preserve spaces
template = template.replace(spaceReplacementRegex, '\u00a0');
if (formatter instanceof Formatter) return Strings.interpolate(template, formatter);
if (formatter instanceof Formatter) return interpolate(template, formatter);
let options: Options | undefined = undefined;
if (dateFormatOrOptions == null || typeof dateFormatOrOptions === 'string') {
@ -117,8 +124,8 @@ export abstract class Formatter
}
if (options.tokenOptions == null) {
const tokenOptions = Strings.getTokensFromTemplate(template).reduce<{
[token: string]: Strings.TokenOptions | undefined;
const tokenOptions = getTokensFromTemplate(template).reduce<{
[token: string]: TokenOptions | undefined;
}>((map, token) => {
map[token.key] = token.options;
return map;
@ -133,7 +140,7 @@ export abstract class Formatter
this._formatter.reset(item, options);
}
return Strings.interpolate(template, this._formatter);
return interpolate(template, this._formatter);
}
protected static fromTemplateCoreAsync<
@ -148,7 +155,7 @@ export abstract class Formatter
): Promise<string> {
// Preserve spaces
template = template.replace(spaceReplacementRegex, '\u00a0');
if (formatter instanceof Formatter) return Strings.interpolateAsync(template, formatter);
if (formatter instanceof Formatter) return interpolateAsync(template, formatter);
let options: Options | undefined = undefined;
if (dateFormatOrOptions == null || typeof dateFormatOrOptions === 'string') {
@ -161,8 +168,8 @@ export abstract class Formatter
}
if (options.tokenOptions == null) {
const tokenOptions = Strings.getTokensFromTemplate(template).reduce<{
[token: string]: Strings.TokenOptions | undefined;
const tokenOptions = getTokensFromTemplate(template).reduce<{
[token: string]: TokenOptions | undefined;
}>((map, token) => {
map[token.key] = token.options;
return map;
@ -177,7 +184,7 @@ export abstract class Formatter
this._formatter.reset(item, options);
}
return Strings.interpolateAsync(template, this._formatter);
return interpolateAsync(template, this._formatter);
}
static has<TOptions extends FormatOptions>(

+ 1
- 1
src/git/parsers/branchParser.ts View File

@ -1,4 +1,4 @@
import { debug } from '../../system';
import { debug } from '../../system/decorators/log';
import { GitBranch } from '../models/branch';
const branchWithTrackingRegex =

+ 3
- 2
src/git/parsers/logParser.ts View File

@ -1,6 +1,7 @@
import { Range } from 'vscode';
import type { Container } from '../../container';
import { Arrays, debug } from '../../system';
import { filterMap } from '../../system/array';
import { debug } from '../../system/decorators/log';
import { normalizePath, relative } from '../../system/path';
import { getLines } from '../../system/string';
import {
@ -525,7 +526,7 @@ export class GitLogParser {
}
if (entry.files !== undefined) {
entry.path = Arrays.filterMap(entry.files, f => (f.path ? f.path : undefined)).join(', ');
entry.path = filterMap(entry.files, f => (f.path ? f.path : undefined)).join(', ');
}
if (first && repoPath === undefined && type === LogType.LogFile && fileName !== undefined) {

+ 1
- 1
src/git/parsers/reflogParser.ts View File

@ -1,4 +1,4 @@
import { debug } from '../../system';
import { debug } from '../../system/decorators/log';
import { GitReflog, GitReflogRecord } from '../models/reflog';
const reflogRegex = /^<r>(.+)<d>(.+?)@{(.+)}<s>(\w*)(.*?)(?::(.*))?$/gm;

+ 1
- 1
src/git/parsers/remoteParser.ts View File

@ -1,4 +1,4 @@
import { debug } from '../../system';
import { debug } from '../../system/decorators/log';
import { GitRemote } from '../models';
import { GitRemoteType } from '../models/remote';
import { RemoteProvider } from '../remotes/provider';

+ 1
- 1
src/git/parsers/tagParser.ts View File

@ -1,4 +1,4 @@
import { debug } from '../../system';
import { debug } from '../../system/decorators/log';
import { GitTag } from '../models';
const tagRegex = /^<n>(.+)<\*r>(.*)<r>(.*)<d>(.*)<ad>(.*)<s>(.*)$/gm;

+ 1
- 1
src/git/parsers/treeParser.ts View File

@ -1,4 +1,4 @@
import { debug } from '../../system';
import { debug } from '../../system/decorators/log';
import { GitTreeEntry } from '../models';
const emptyStr = '';

+ 11
- 17
src/git/remotes/custom.ts View File

@ -1,6 +1,6 @@
import { Range, Uri } from 'vscode';
import { RemotesUrlsConfig } from '../../configuration';
import { Strings } from '../../system';
import { interpolate } from '../../system/string';
import { Repository } from '../models/repository';
import { RemoteProvider } from './provider';
@ -28,29 +28,26 @@ export class CustomRemote extends RemoteProvider {
}
protected override getUrlForRepository(): string {
return this.encodeUrl(Strings.interpolate(this.urls.repository, this.getContext()));
return this.encodeUrl(interpolate(this.urls.repository, this.getContext()));
}
protected getUrlForBranches(): string {
return this.encodeUrl(Strings.interpolate(this.urls.branches, this.getContext()));
return this.encodeUrl(interpolate(this.urls.branches, this.getContext()));
}
protected getUrlForBranch(branch: string): string {
return this.encodeUrl(Strings.interpolate(this.urls.branch, this.getContext({ branch: branch })));
return this.encodeUrl(interpolate(this.urls.branch, this.getContext({ branch: branch })));
}
protected getUrlForCommit(sha: string): string {
return this.encodeUrl(Strings.interpolate(this.urls.commit, this.getContext({ id: sha })));
return this.encodeUrl(interpolate(this.urls.commit, this.getContext({ id: sha })));
}
protected override getUrlForComparison(base: string, compare: string, notation: '..' | '...'): string | undefined {
if (this.urls.comparison == null) return undefined;
return this.encodeUrl(
Strings.interpolate(
this.urls.comparison,
this.getContext({ ref1: base, ref2: compare, notation: notation }),
),
interpolate(this.urls.comparison, this.getContext({ ref1: base, ref2: compare, notation: notation })),
);
}
@ -58,9 +55,9 @@ export class CustomRemote extends RemoteProvider {
let line;
if (range != null) {
if (range.start.line === range.end.line) {
line = Strings.interpolate(this.urls.fileLine, { line: range.start.line });
line = interpolate(this.urls.fileLine, { line: range.start.line });
} else {
line = Strings.interpolate(this.urls.fileRange, { start: range.start.line, end: range.end.line });
line = interpolate(this.urls.fileRange, { start: range.start.line, end: range.end.line });
}
} else {
line = '';
@ -68,14 +65,11 @@ export class CustomRemote extends RemoteProvider {
let url;
if (sha) {
url = Strings.interpolate(this.urls.fileInCommit, this.getContext({ id: sha, file: fileName, line: line }));
url = interpolate(this.urls.fileInCommit, this.getContext({ id: sha, file: fileName, line: line }));
} else if (branch) {
url = Strings.interpolate(
this.urls.fileInBranch,
this.getContext({ branch: branch, file: fileName, line: line }),
);
url = interpolate(this.urls.fileInBranch, this.getContext({ branch: branch, file: fileName, line: line }));
} else {
url = Strings.interpolate(this.urls.file, this.getContext({ file: fileName, line: line }));
url = interpolate(this.urls.file, this.getContext({ file: fileName, line: line }));
}
const decodeHash = url.includes('#');

+ 0
- 15
src/quickpicks.ts View File

@ -1,15 +0,0 @@
import { configuration } from './configuration';
export function getQuickPickIgnoreFocusOut() {
return !configuration.get('advanced.quickPick.closeOnFocusOut');
}
export * from './quickpicks/quickPicksItems';
export * from './quickpicks/gitQuickPickItems';
export * from './quickpicks/commitQuickPickItems';
export * from './quickpicks/commitPicker';
export * from './quickpicks/modePicker';
export * from './quickpicks/referencePicker';
export * from './quickpicks/remoteProviderPicker';
export * from './quickpicks/repositoryPicker';

+ 4
- 7
src/quickpicks/commitPicker.ts View File

@ -3,15 +3,12 @@ import { configuration } from '../configuration';
import { Container } from '../container';
import { GitCommit, GitLog, GitStash, GitStashCommit } from '../git/models';
import { KeyboardScope, Keys } from '../keyboard';
import {
CommandQuickPickItem,
CommitQuickPickItem,
Directive,
DirectiveQuickPickItem,
getQuickPickIgnoreFocusOut,
} from '../quickpicks';
import { CommandQuickPickItem } from '../quickpicks/items/common';
import { filter, map } from '../system/iterable';
import { isPromise } from '../system/promise';
import { getQuickPickIgnoreFocusOut } from '../system/utils';
import { Directive, DirectiveQuickPickItem } from './items/directive';
import { CommitQuickPickItem } from './items/gitCommands';
export namespace CommitPicker {
export async function show(

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save