Переглянути джерело

Reorganizes git models/parsers/formatters imports

Reorganizes local git support to exclude from web
Swaps sha1 usages to md5 to avoid needing sha1 on the web (md5 is required by Gravatar)
Avoids crypto-browserfy and imports md5.js directly
Uses platform crypto for random nonce strings
main
Eric Amodio 2 роки тому
джерело
коміт
1d93f9cdbd
197 змінених файлів з 6658 додано та 6847 видалено
  1. +1
    -1
      .eslintrc.browser.json
  2. +3
    -3
      package.json
  3. +13
    -0
      src/@types/md5.js.d.ts
  4. +2
    -1
      src/annotations/annotations.ts
  5. +1
    -1
      src/annotations/autolinks.ts
  6. +1
    -1
      src/annotations/blameAnnotationProvider.ts
  7. +2
    -1
      src/annotations/gutterBlameAnnotationProvider.ts
  8. +1
    -1
      src/annotations/gutterChangesAnnotationProvider.ts
  9. +1
    -1
      src/annotations/gutterHeatmapBlameAnnotationProvider.ts
  10. +3
    -1
      src/annotations/lineAnnotationController.ts
  11. +1
    -1
      src/avatars.ts
  12. +2
    -1
      src/codelens/codeLensProvider.ts
  13. +10
    -1
      src/commands/common.ts
  14. +2
    -1
      src/commands/createPullRequestOnRemote.ts
  15. +1
    -1
      src/commands/diffLineWithPrevious.ts
  16. +1
    -1
      src/commands/diffLineWithWorking.ts
  17. +1
    -1
      src/commands/diffWith.ts
  18. +1
    -1
      src/commands/diffWithNext.ts
  19. +1
    -1
      src/commands/diffWithPrevious.ts
  20. +1
    -1
      src/commands/diffWithRevision.ts
  21. +1
    -1
      src/commands/diffWithRevisionFrom.ts
  22. +1
    -1
      src/commands/diffWithWorking.ts
  23. +1
    -1
      src/commands/externalDiff.ts
  24. +1
    -1
      src/commands/git/branch.ts
  25. +1
    -1
      src/commands/git/cherry-pick.ts
  26. +1
    -1
      src/commands/git/coauthors.ts
  27. +1
    -1
      src/commands/git/fetch.ts
  28. +1
    -1
      src/commands/git/log.ts
  29. +1
    -1
      src/commands/git/merge.ts
  30. +1
    -1
      src/commands/git/pull.ts
  31. +1
    -1
      src/commands/git/push.ts
  32. +1
    -1
      src/commands/git/rebase.ts
  33. +1
    -1
      src/commands/git/reset.ts
  34. +1
    -1
      src/commands/git/revert.ts
  35. +2
    -1
      src/commands/git/search.ts
  36. +1
    -1
      src/commands/git/show.ts
  37. +6
    -23
      src/commands/git/stash.ts
  38. +1
    -1
      src/commands/git/status.ts
  39. +1
    -1
      src/commands/git/switch.ts
  40. +1
    -1
      src/commands/git/tag.ts
  41. +2
    -2
      src/commands/gitCommands.actions.ts
  42. +1
    -1
      src/commands/openBranchOnRemote.ts
  43. +1
    -1
      src/commands/openBranchesOnRemote.ts
  44. +1
    -1
      src/commands/openCommitOnRemote.ts
  45. +1
    -1
      src/commands/openComparisonOnRemote.ts
  46. +1
    -1
      src/commands/openFileAtRevision.ts
  47. +1
    -1
      src/commands/openFileAtRevisionFrom.ts
  48. +2
    -1
      src/commands/openFileOnRemote.ts
  49. +2
    -1
      src/commands/openOnRemote.ts
  50. +1
    -1
      src/commands/openRepoOnRemote.ts
  51. +5
    -6
      src/commands/quickCommand.steps.ts
  52. +2
    -1
      src/commands/remoteProviders.ts
  53. +1
    -1
      src/commands/searchCommits.ts
  54. +1
    -1
      src/commands/showCommitsInView.ts
  55. +1
    -1
      src/commands/showQuickBranchHistory.ts
  56. +1
    -1
      src/commands/showQuickCommit.ts
  57. +1
    -1
      src/commands/showQuickCommitFile.ts
  58. +1
    -1
      src/commands/showQuickFileHistory.ts
  59. +1
    -1
      src/commands/stashApply.ts
  60. +1
    -1
      src/constants.ts
  61. +6
    -14
      src/container.ts
  62. +2
    -5
      src/emojis.ts
  63. +10
    -0
      src/env/browser/crypto.ts
  64. +11
    -0
      src/env/browser/git.ts
  65. +5
    -0
      src/env/browser/platform.ts
  66. +9
    -0
      src/env/node/crypto.ts
  67. +12
    -0
      src/env/node/git.ts
  68. +7
    -32
      src/env/node/git/git.ts
  69. +84
    -39
      src/env/node/git/localGitProvider.ts
  70. +3
    -3
      src/env/node/git/locator.ts
  71. +1
    -1
      src/env/node/git/shell.ts
  72. +4
    -0
      src/env/node/platform.ts
  73. +2
    -2
      src/extension.ts
  74. +23
    -0
      src/git/commandOptions.ts
  75. +17
    -0
      src/git/errors.ts
  76. +4
    -0
      src/git/formatters.ts
  77. +2
    -9
      src/git/formatters/commitFormatter.ts
  78. +0
    -4
      src/git/formatters/formatters.ts
  79. +1
    -1
      src/git/fsProvider.ts
  80. +3
    -4
      src/git/gitProvider.ts
  81. +6
    -6
      src/git/gitProviderService.ts
  82. +1
    -1
      src/git/gitUri.ts
  83. +28
    -0
      src/git/models.ts
  84. +3
    -2
      src/git/models/branch.ts
  85. +2
    -2
      src/git/models/commit.ts
  86. +2
    -0
      src/git/models/diff.ts
  87. +1
    -1
      src/git/models/logCommit.ts
  88. +1
    -1
      src/git/models/merge.ts
  89. +1
    -1
      src/git/models/rebase.ts
  90. +0
    -27
      src/git/models/reference.ts
  91. +1
    -1
      src/git/models/reflog.ts
  92. +1
    -1
      src/git/models/remote.ts
  93. +15
    -22
      src/git/models/repository.ts
  94. +1
    -1
      src/git/models/stashCommit.ts
  95. +1
    -1
      src/git/models/status.ts
  96. +1
    -1
      src/git/models/tag.ts
  97. +13
    -0
      src/git/parsers.ts
  98. +1
    -1
      src/git/parsers/blameParser.ts
  99. +1
    -1
      src/git/parsers/logParser.ts
  100. +0
    -13
      src/git/parsers/parsers.ts

+ 1
- 1
.eslintrc.browser.json Переглянути файл

@ -3,7 +3,7 @@
"env": {
"worker": true
},
"ignorePatterns": ["src/webviews/apps/**/*", "src/env/node/*"],
"ignorePatterns": ["src/webviews/apps/**/*", "src/env/node/**/*"],
"parserOptions": {
"project": "tsconfig.browser.json"
}

+ 3
- 3
package.json Переглянути файл

@ -10134,10 +10134,10 @@
"@octokit/graphql": "4.8.0",
"@vscode/codicons": "0.0.27",
"chroma-js": "2.1.2",
"crypto-browserify": "3.12.0",
"dayjs": "1.10.7",
"iconv-lite": "0.6.3",
"lodash-es": "4.17.21",
"md5.js": "1.3.5",
"node-fetch": "3.0.0",
"path-browserify": "1.0.1",
"sortablejs": "1.14.0"
@ -10157,7 +10157,7 @@
"cross-env": "7.0.3",
"csp-html-webpack-plugin": "5.1.0",
"css-loader": "6.5.1",
"esbuild": "0.14.7",
"esbuild": "0.14.8",
"esbuild-loader": "2.18.0",
"eslint": "8.5.0",
"eslint-cli": "1.1.1",
@ -10185,7 +10185,7 @@
"webpack-cli": "4.9.1"
},
"resolutions": {
"esbuild": "0.14.7",
"esbuild": "0.14.8",
"node-fetch": "2.6.1",
"semver-regex": "3.1.3",
"trim-newlines": "4.0.2"

+ 13
- 0
src/@types/md5.js.d.ts Переглянути файл

@ -0,0 +1,13 @@
/// <reference types="node" />
declare module 'md5.js' {
import type { Hash } from 'crypto';
export = MD5;
interface MD5 extends Hash {
new (): MD5;
}
declare const MD5: MD5;
}

+ 2
- 1
src/annotations/annotations.ts Переглянути файл

@ -15,7 +15,8 @@ import { HeatmapLocations } from '../config';
import { Config, configuration } from '../configuration';
import { Colors, GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter, GitCommit } from '../git/git';
import { CommitFormatOptions, CommitFormatter } from '../git/formatters';
import { GitCommit } from '../git/models';
import { Strings } from '../system';
import { toRgba } from '../webviews/apps/shared/colors';

+ 1
- 1
src/annotations/autolinks.ts Переглянути файл

@ -3,7 +3,7 @@ import { ConfigurationChangeEvent, Disposable } from 'vscode';
import { AutolinkReference, configuration } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitRemote, IssueOrPullRequest } from '../git/git';
import { GitRemote, IssueOrPullRequest } from '../git/models';
import { Logger } from '../logger';
import { Dates, debug, Encoding, Iterables, Promises, Strings } from '../system';

+ 1
- 1
src/annotations/blameAnnotationProvider.ts Переглянути файл

@ -2,8 +2,8 @@
import { CancellationToken, Disposable, Hover, languages, Position, Range, TextDocument, TextEditor } from 'vscode';
import { FileAnnotationType } from '../config';
import { Container } from '../container';
import { GitBlame, GitBlameCommit, GitCommit } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitBlame, GitBlameCommit, GitCommit } from '../git/models';
import { Hovers } from '../hovers/hovers';
import { log } from '../system';
import { GitDocumentState, TrackedDocument } from '../trackers/gitDocumentTracker';

+ 2
- 1
src/annotations/gutterBlameAnnotationProvider.ts Переглянути файл

@ -3,7 +3,8 @@ import { DecorationOptions, Range, TextEditor, ThemableDecorationAttachmentRende
import { FileAnnotationType, GravatarDefaultStyle } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter, GitBlame, GitBlameCommit } from '../git/git';
import { CommitFormatOptions, CommitFormatter } from '../git/formatters';
import { GitBlame, GitBlameCommit } from '../git/models';
import { Logger } from '../logger';
import { Arrays, Iterables, log, Stopwatch, Strings } from '../system';
import { GitDocumentState } from '../trackers/gitDocumentTracker';

+ 1
- 1
src/annotations/gutterChangesAnnotationProvider.ts Переглянути файл

@ -15,7 +15,7 @@ import {
} from 'vscode';
import { FileAnnotationType } from '../configuration';
import { Container } from '../container';
import { GitDiff, GitLogCommit } from '../git/git';
import { GitDiff, GitLogCommit } from '../git/models';
import { Hovers } from '../hovers/hovers';
import { Logger } from '../logger';
import { log, Stopwatch } from '../system';

+ 1
- 1
src/annotations/gutterHeatmapBlameAnnotationProvider.ts Переглянути файл

@ -2,7 +2,7 @@
import { Range, TextEditor, TextEditorDecorationType } from 'vscode';
import { FileAnnotationType } from '../configuration';
import { Container } from '../container';
import { GitBlameCommit } from '../git/git';
import { GitBlameCommit } from '../git/models';
import { Logger } from '../logger';
import { log, Stopwatch } from '../system';
import { GitDocumentState } from '../trackers/gitDocumentTracker';

+ 3
- 1
src/annotations/lineAnnotationController.ts Переглянути файл

@ -14,7 +14,9 @@ import {
import { configuration } from '../configuration';
import { GlyphChars, isTextEditor } from '../constants';
import { Container } from '../container';
import { Authentication, CommitFormatter, GitBlameCommit, PullRequest } from '../git/git';
import { CommitFormatter } from '../git/formatters';
import { GitBlameCommit, PullRequest } from '../git/models';
import { Authentication } from '../git/remotes/provider';
import { LogCorrelationContext, Logger } from '../logger';
import { debug, Iterables, log, Promises } from '../system';
import { LinesChangeEvent, LineSelection } from '../trackers/gitLineTracker';

+ 1
- 1
src/avatars.ts Переглянути файл

@ -3,7 +3,7 @@ import { EventEmitter, Uri } from 'vscode';
import { GravatarDefaultStyle } from './config';
import { GlobalState } from './constants';
import { Container } from './container';
import { GitRevisionReference } from './git/git';
import { GitRevisionReference } from './git/models';
import { Dates, Functions, Iterables, Strings } from './system';
import { ContactPresenceStatus } from './vsls/vsls';

+ 2
- 1
src/codelens/codeLensProvider.ts Переглянути файл

@ -38,8 +38,9 @@ import {
} from '../configuration';
import { BuiltInCommands, DocumentSchemes } from '../constants';
import { Container } from '../container';
import { GitBlame, GitBlameLines, GitCommit, RemoteResourceType } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitBlame, GitBlameLines, GitCommit } from '../git/models';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { Functions, Iterables } from '../system';

+ 10
- 1
src/commands/common.ts Переглянути файл

@ -19,8 +19,17 @@ import {
import type { Action, ActionContext } from '../api/gitlens';
import { BuiltInCommands, DocumentSchemes, ImageMimetypes } from '../constants';
import { Container } from '../container';
import { GitBranch, GitCommit, GitContributor, GitFile, GitReference, GitRemote, GitTag, Repository } from '../git/git';
import { GitUri } from '../git/gitUri';
import {
GitBranch,
GitCommit,
GitContributor,
GitFile,
GitReference,
GitRemote,
GitTag,
Repository,
} from '../git/models';
import { Logger } from '../logger';
import { CommandQuickPickItem, RepositoryPicker } from '../quickpicks';
import { ViewNode, ViewRefNode } from '../views/nodes';

+ 2
- 1
src/commands/createPullRequestOnRemote.ts Переглянути файл

@ -1,6 +1,7 @@
'use strict';
import { Container } from '../container';
import { GitRemote, RemoteProvider, RemoteResource, RemoteResourceType } from '../git/git';
import { GitRemote } from '../git/models';
import { RemoteProvider, RemoteResource, RemoteResourceType } from '../git/remotes/provider';
import { Command, command, Commands, executeCommand } from './common';
import { OpenOnRemoteCommandArgs } from './openOnRemote';

+ 1
- 1
src/commands/diffLineWithPrevious.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitCommit } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitCommit } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, command, Commands, executeCommand, getCommandUri } from './common';

+ 1
- 1
src/commands/diffLineWithWorking.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { Container } from '../container';
import { GitCommit, GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitCommit, GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, command, Commands, executeCommand, getCommandUri } from './common';

+ 1
- 1
src/commands/diffWith.ts Переглянути файл

@ -3,8 +3,8 @@ import * as paths from 'path';
import { commands, Range, TextDocumentShowOptions, Uri, ViewColumn } from 'vscode';
import { BuiltInCommands, GlyphChars } from '../constants';
import { Container } from '../container';
import { GitCommit, GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitCommit, GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { command, Command, Commands } from './common';

+ 1
- 1
src/commands/diffWithNext.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { Range, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitLogCommit } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitLogCommit } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, command, CommandContext, Commands, executeCommand, getCommandUri } from './common';

+ 1
- 1
src/commands/diffWithPrevious.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitCommit, GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitCommit, GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import {

+ 1
- 1
src/commands/diffWithRevision.ts Переглянути файл

@ -2,8 +2,8 @@
import { TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { GlyphChars, quickPickTitleMaxChars } from '../constants';
import { Container } from '../container';
import { GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, CommitPicker } from '../quickpicks';

+ 1
- 1
src/commands/diffWithRevisionFrom.ts Переглянути файл

@ -3,8 +3,8 @@ import * as paths from 'path';
import { TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { GlyphChars, quickPickTitleMaxChars } from '../constants';
import { Container } from '../container';
import { GitReference, GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitReference, GitRevision } from '../git/models';
import { Messages } from '../messages';
import { ReferencePicker, StashPicker } from '../quickpicks';
import { Strings } from '../system';

+ 1
- 1
src/commands/diffWithWorking.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { Container } from '../container';
import { GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, command, Commands, executeCommand, getCommandUri } from './common';

+ 1
- 1
src/commands/externalDiff.ts Переглянути файл

@ -3,8 +3,8 @@ import { env, SourceControlResourceState, Uri, window } from 'vscode';
import { ScmResource } from '../@types/vscode.git.resources';
import { ScmResourceGroupType, ScmStatus } from '../@types/vscode.git.resources.enums';
import { Container } from '../container';
import { GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Arrays } from '../system';

+ 1
- 1
src/commands/git/branch.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { QuickInputButtons } from 'vscode';
import { Container } from '../../container';
import { GitBranchReference, GitReference, Repository } from '../../git/git';
import { GitBranchReference, GitReference, Repository } from '../../git/models';
import { FlagsQuickPickItem, QuickPickItemOfT } from '../../quickpicks';
import { Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 1
- 1
src/commands/git/cherry-pick.ts Переглянути файл

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

+ 1
- 1
src/commands/git/coauthors.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { commands } from 'vscode';
import { Container } from '../../container';
import { GitContributor, Repository } from '../../git/git';
import { GitContributor, Repository } from '../../git/models';
import { Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {

+ 1
- 1
src/commands/git/fetch.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitBranchReference, GitReference, Repository } from '../../git/git';
import { GitBranchReference, GitReference, Repository } from '../../git/models';
import { FlagsQuickPickItem } from '../../quickpicks';
import { Arrays, Dates, Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 1
- 1
src/commands/git/log.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { GlyphChars, quickPickTitleMaxChars } from '../../constants';
import { Container } from '../../container';
import { GitLog, GitLogCommit, GitReference, Repository } from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { GitLog, GitLogCommit, GitReference, Repository } from '../../git/models';
import { Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { GitCommandsCommand } from '../gitCommands';

+ 1
- 1
src/commands/git/merge.ts Переглянути файл

@ -1,6 +1,6 @@
'use strict';
import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/git';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 1
- 1
src/commands/git/pull.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/git';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
import { Arrays, Dates, Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 1
- 1
src/commands/git/push.ts Переглянути файл

@ -2,7 +2,7 @@
import { configuration } from '../../configuration';
import { BuiltInGitConfiguration, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/git';
import { GitBranch, GitBranchReference, GitReference, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
import { Arrays, Dates, Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 1
- 1
src/commands/git/rebase.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { env } from 'vscode';
import { Container } from '../../container';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/git';
import { GitBranch, GitLog, GitReference, GitRevision, Repository } from '../../git/models';
import { Directive, DirectiveQuickPickItem, FlagsQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 1
- 1
src/commands/git/reset.ts Переглянути файл

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

+ 1
- 1
src/commands/git/revert.ts Переглянути файл

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

+ 2
- 1
src/commands/git/search.ts Переглянути файл

@ -1,7 +1,8 @@
'use strict';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitLog, GitLogCommit, Repository, SearchOperators, searchOperators, SearchPattern } from '../../git/git';
import { GitLog, GitLogCommit, Repository } from '../../git/models';
import { searchOperators, SearchOperators, SearchPattern } from '../../git/search';
import { ActionQuickPickItem, QuickPickItemOfT } from '../../quickpicks';
import { Strings } from '../../system';
import { SearchResultsNode } from '../../views/nodes';

+ 1
- 1
src/commands/git/show.ts Переглянути файл

@ -1,6 +1,6 @@
'use strict';
import { Container } from '../../container';
import { GitAuthor, GitLogCommit, GitRevisionReference, GitStashCommit, Repository } from '../../git/git';
import { GitAuthor, GitLogCommit, GitRevisionReference, GitStashCommit, Repository } from '../../git/models';
import { CommandQuickPickItem, CommitFilesQuickPickItem, GitCommandQuickPickItem } from '../../quickpicks';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {

+ 6
- 23
src/commands/git/stash.ts Переглянути файл

@ -2,8 +2,9 @@
import { QuickInputButtons, QuickPickItem, Uri, window } from 'vscode';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitReference, GitStashCommit, GitStashReference, Repository, RunError } from '../../git/git';
import { StashApplyError, StashApplyErrorReason } from '../../git/errors';
import { GitUri } from '../../git/gitUri';
import { GitReference, GitStashCommit, GitStashReference, Repository } from '../../git/models';
import { Logger } from '../../logger';
import { Messages } from '../../messages';
import { FlagsQuickPickItem, QuickPickItemOfT } from '../../quickpicks';
@ -291,32 +292,14 @@ export class StashGitCommand extends QuickCommand {
} catch (ex) {
Logger.error(ex, context.title);
if (ex instanceof Error) {
const msg: string = ex.message ?? '';
if (msg.includes('Your local changes to the following files would be overwritten by merge')) {
if (ex instanceof StashApplyError) {
if (ex.reason === StashApplyErrorReason.WorkingChanges) {
void window.showWarningMessage(
'Unable to apply stash. Your working tree changes would be overwritten. Please commit or stash your changes before trying again',
);
return;
}
if (
(msg.includes('Auto-merging') && msg.includes('CONFLICT')) ||
(ex instanceof RunError &&
((ex.stdout.includes('Auto-merging') && ex.stdout.includes('CONFLICT')) ||
ex.stdout.includes('needs merge')))
) {
void window.showInformationMessage('Stash applied with conflicts');
return;
} else {
void Messages.showGenericErrorMessage(ex.message);
}
void Messages.showGenericErrorMessage(
`Unable to apply stash \u2014 ${msg.trim().replace(/\n+?/g, '; ')}`,
);
return;
}
}
}

+ 1
- 1
src/commands/git/status.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitReference, GitStatus, Repository } from '../../git/git';
import { GitReference, GitStatus, Repository } from '../../git/models';
import { CommandQuickPickItem, GitCommandQuickPickItem } from '../../quickpicks';
import { Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 1
- 1
src/commands/git/switch.ts Переглянути файл

@ -2,7 +2,7 @@
import { ProgressLocation, QuickPickItem, window } from 'vscode';
import { BranchSorting } from '../../config';
import { Container } from '../../container';
import { GitReference, Repository } from '../../git/git';
import { GitReference, Repository } from '../../git/models';
import { Arrays } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';
import {

+ 1
- 1
src/commands/git/tag.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { QuickInputButtons, QuickPickItem } from 'vscode';
import { Container } from '../../container';
import { GitReference, GitTagReference, Repository } from '../../git/git';
import { GitReference, GitTagReference, Repository } from '../../git/models';
import { FlagsQuickPickItem, QuickPickItemOfT } from '../../quickpicks';
import { Strings } from '../../system';
import { ViewsWithRepositoryFolders } from '../../views/viewBase';

+ 2
- 2
src/commands/gitCommands.actions.ts Переглянути файл

@ -13,6 +13,7 @@ import {
} from '../commands';
import { FileAnnotationType } from '../configuration';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import {
GitBranchReference,
GitContributor,
@ -25,8 +26,7 @@ import {
GitStashReference,
GitTagReference,
Repository,
} from '../git/git';
import { GitUri } from '../git/gitUri';
} from '../git/models';
import { RepositoryPicker } from '../quickpicks';
import { ViewsWithRepositoryFolders } from '../views/viewBase';
import { ResetGitCommandArgs } from './git/reset';

+ 1
- 1
src/commands/openBranchOnRemote.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { RemoteResourceType } from '../git/git';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { CommandQuickPickItem, ReferencePicker, ReferencesQuickPickIncludes } from '../quickpicks';
import {

+ 1
- 1
src/commands/openBranchesOnRemote.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { RemoteResourceType } from '../git/git';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import {
ActiveEditorCommand,

+ 1
- 1
src/commands/openCommitOnRemote.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { Container } from '../container';
import { RemoteResourceType } from '../git/git';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { Messages } from '../messages';
import {

+ 1
- 1
src/commands/openComparisonOnRemote.ts Переглянути файл

@ -1,6 +1,6 @@
'use strict';
import { window } from 'vscode';
import { RemoteResourceType } from '../git/git';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import { ResultsCommitsNode } from '../views/nodes';
import { Command, command, CommandContext, Commands, executeCommand } from './common';

+ 1
- 1
src/commands/openFileAtRevision.ts Переглянути файл

@ -3,8 +3,8 @@ import { TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { FileAnnotationType } from '../configuration';
import { GlyphChars, quickPickTitleMaxChars } from '../constants';
import { Container } from '../container';
import { GitRevision } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, CommitPicker } from '../quickpicks';

+ 1
- 1
src/commands/openFileAtRevisionFrom.ts Переглянути файл

@ -4,8 +4,8 @@ import { TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { FileAnnotationType } from '../configuration';
import { GlyphChars, quickPickTitleMaxChars } from '../constants';
import { Container } from '../container';
import { GitReference } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitReference } from '../git/models';
import { Messages } from '../messages';
import { ReferencePicker, StashPicker } from '../quickpicks';
import { Strings } from '../system';

+ 2
- 1
src/commands/openFileOnRemote.ts Переглянути файл

@ -4,8 +4,9 @@ import { UriComparer } from '../comparers';
import { BranchSorting, TagSorting } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitBranch, GitRevision, RemoteResourceType } from '../git/git';
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';

+ 2
- 1
src/commands/openOnRemote.ts Переглянути файл

@ -1,7 +1,8 @@
'use strict';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitRemote, GitRevision, RemoteProvider, RemoteResource, RemoteResourceType } from '../git/git';
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';

+ 1
- 1
src/commands/openRepoOnRemote.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { RemoteResourceType } from '../git/git';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/remotes/provider';
import { Logger } from '../logger';
import {
ActiveEditorCommand,

+ 5
- 6
src/commands/quickCommand.steps.ts Переглянути файл

@ -3,6 +3,8 @@ import { QuickInputButton, QuickPick } from 'vscode';
import { BranchSorting, configuration, TagSorting } from '../configuration';
import { GlyphChars, quickPickTitleMaxChars } from '../constants';
import { Container } from '../container';
import { PagedResult } from '../git/gitProvider';
import { GitUri } from '../git/gitUri';
import {
BranchSortOptions,
GitBranch,
@ -19,14 +21,11 @@ import {
GitStatus,
GitTag,
GitTagReference,
RemoteProvider,
RemoteResourceType,
Repository,
SearchPattern,
TagSortOptions,
} from '../git/git';
import { PagedResult } from '../git/gitProvider';
import { GitUri } from '../git/gitUri';
} from '../git/models';
import { RemoteProvider, RemoteResourceType } from '../git/remotes/provider';
import { SearchPattern } from '../git/search';
import {
BranchQuickPickItem,
CommandQuickPickItem,

+ 2
- 1
src/commands/remoteProviders.ts Переглянути файл

@ -1,6 +1,7 @@
'use strict';
import { Container } from '../container';
import { GitCommit, GitRemote, Repository, RichRemoteProvider } from '../git/git';
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, Commands, isCommandContextViewNodeHasRemote } from './common';

+ 1
- 1
src/commands/searchCommits.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { executeGitCommand } from '../commands';
import { Container } from '../container';
import { SearchPattern } from '../git/git';
import { SearchPattern } from '../git/search';
import { SearchResultsNode } from '../views/nodes';
import { Command, command, CommandContext, Commands, isCommandContextViewNodeHasRepository } from './common';

+ 1
- 1
src/commands/showCommitsInView.ts Переглянути файл

@ -2,8 +2,8 @@
import { TextEditor, Uri } from 'vscode';
import { executeGitCommand } from '../commands';
import { Container } from '../container';
import { SearchPattern } from '../git/git';
import { GitUri } from '../git/gitUri';
import { SearchPattern } from '../git/search';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system';

+ 1
- 1
src/commands/showQuickBranchHistory.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitReference } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitReference } from '../git/models';
import { ActiveEditorCachedCommand, command, CommandContext, Commands, getCommandUri } from './common';
import { executeGitCommand } from './gitCommands';

+ 1
- 1
src/commands/showQuickCommit.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitCommit, GitLog, GitLogCommit } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitCommit, GitLog, GitLogCommit } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import {

+ 1
- 1
src/commands/showQuickCommitFile.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { Container } from '../container';
import { GitBlameCommit, GitCommit, GitLog, GitLogCommit } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitBlameCommit, GitCommit, GitLog, GitLogCommit } from '../git/models';
import { Logger } from '../logger';
import { Messages } from '../messages';
import {

+ 1
- 1
src/commands/showQuickFileHistory.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import { Range, TextEditor, Uri } from 'vscode';
import { Container } from '../container';
import { GitBranch, GitLog, GitReference, GitTag } from '../git/git';
import { GitUri } from '../git/gitUri';
import { GitBranch, GitLog, GitReference, GitTag } from '../git/models';
import { CommandQuickPickItem } from '../quickpicks';
import { ActiveEditorCachedCommand, command, CommandContext, Commands, getCommandUri } from './common';
import { executeGitCommand } from './gitCommands';

+ 1
- 1
src/commands/stashApply.ts Переглянути файл

@ -1,6 +1,6 @@
'use strict';
import { GitActions } from '../commands';
import { GitStashCommit, GitStashReference } from '../git/git';
import { GitStashCommit, GitStashReference } from '../git/models';
import { CommandQuickPickItem } from '../quickpicks';
import {
command,

+ 1
- 1
src/constants.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { commands, TextDocument, TextEditor, window } from 'vscode';
import { ViewShowBranchComparison } from './config';
import { SearchPattern } from './git/git';
import { SearchPattern } from './git/search';
export const quickPickTitleMaxChars = 80;

+ 6
- 14
src/container.ts Переглянути файл

@ -1,14 +1,6 @@
'use strict';
import {
commands,
ConfigurationChangeEvent,
ConfigurationScope,
env,
Event,
EventEmitter,
ExtensionContext,
UIKind,
} from 'vscode';
import { commands, ConfigurationChangeEvent, ConfigurationScope, Event, EventEmitter, ExtensionContext } from 'vscode';
import { getSupportedGitProviders } from '@env/git';
import { Autolinks } from './annotations/autolinks';
import { FileAnnotationController } from './annotations/fileAnnotationController';
import { LineAnnotationController } from './annotations/lineAnnotationController';
@ -24,8 +16,7 @@ import {
FileAnnotationType,
} from './configuration';
import { GitFileSystemProvider } from './git/fsProvider';
import { GitProviderId, GitProviderService } from './git/gitProviderService';
import { LocalGitProvider } from './git/providers/localGitProvider';
import { GitProviderService } from './git/gitProviderService';
import { LineHoverController } from './hovers/lineHoverController';
import { Keyboard } from './keyboard';
import { Logger } from './logger';
@ -155,8 +146,9 @@ export class Container {
@log()
private registerGitProviders() {
if (env.uiKind !== UIKind.Web) {
this._context.subscriptions.push(this._git.register(GitProviderId.Git, new LocalGitProvider(this)));
const providers = getSupportedGitProviders(this);
for (const provider of providers) {
this._context.subscriptions.push(this._git.register(provider.descriptor.id, provider));
}
this._git.registrationComplete();

+ 2
- 5
src/emojis.ts Переглянути файл

@ -1,11 +1,8 @@
'use strict';
import * as emojis from './emojis.json';
import emojis from './emojis.json';
const emojiMap = (emojis as any).default as Record<string, string>;
const emojiRegex = /:([-+_a-z0-9]+):/g;
export function emojify(message: string) {
return message.replace(emojiRegex, (s, code) => {
return emojiMap[code] || s;
});
return message.replace(emojiRegex, (s, code) => (emojis as Record<string, string>)[code] || s);
}

+ 10
- 0
src/env/browser/crypto.ts Переглянути файл

@ -0,0 +1,10 @@
import MD5 from 'md5.js';
import { base64 } from './base64';
export function getNonce(): string {
return base64(globalThis.crypto.getRandomValues(new Uint8Array(16)));
}
export function md5(data: string | Uint8Array, encoding: 'base64' | 'hex' = 'base64'): string {
return new MD5().update(data).digest(encoding);
}

+ 11
- 0
src/env/browser/git.ts Переглянути файл

@ -0,0 +1,11 @@
import { Container } from '../../container';
import { GitCommandOptions } from '../../git/commandOptions';
import { GitProvider } from '../../git/gitProvider';
export function git(_options: GitCommandOptions, ..._args: any[]): Promise<string | Buffer> {
return Promise.resolve('');
}
export function getSupportedGitProviders(_container: Container): GitProvider[] {
return [];
}

+ 5
- 0
src/env/browser/platform.ts Переглянути файл

@ -0,0 +1,5 @@
export const isWeb = true;
export const isWindows =
(navigator as any)?.userAgentData?.platform === 'Windows' ||
navigator.platform === 'Win32' ||
navigator.platform === 'Win64';

+ 9
- 0
src/env/node/crypto.ts Переглянути файл

@ -0,0 +1,9 @@
import { createHash, randomBytes } from 'crypto';
export function getNonce(): string {
return randomBytes(16).toString('base64');
}
export function md5(data: string | Uint8Array, encoding: 'base64' | 'hex' = 'base64'): string {
return createHash('md5').update(data).digest(encoding);
}

+ 12
- 0
src/env/node/git.ts Переглянути файл

@ -0,0 +1,12 @@
import { Container } from '../../container';
import { GitProvider } from '../../git/gitProvider';
import { LocalGitProvider } from './git/localGitProvider';
import { isWeb } from './platform';
export { git } from './git/git';
export function getSupportedGitProviders(container: Container): GitProvider[] {
if (isWeb) return [];
return [new LocalGitProvider(container)];
}

src/git/git.ts → src/env/node/git/git.ts Переглянути файл

@ -3,24 +3,16 @@
import * as paths from 'path';
import { Uri, window, workspace } from 'vscode';
import { hrtime } from '@env/hrtime';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { Paths, Strings, Versions } from '../system';
import { GlyphChars } from '../../../constants';
import { Container } from '../../../container';
import { GitCommandOptions, GitErrorHandling } from '../../../git/commandOptions';
import { GitDiffFilter, GitRevision } from '../../../git/models';
import { GitBranchParser, GitLogParser, GitReflogParser, GitStashParser, GitTagParser } from '../../../git/parsers';
import { Logger } from '../../../logger';
import { Paths, Strings, Versions } from '../../../system';
import { GitLocation } from './locator';
import { GitRevision } from './models/models';
import { GitBranchParser, GitLogParser, GitReflogParser, GitStashParser, GitTagParser } from './parsers/parsers';
import { fsExists, run, RunError, RunOptions } from './shell';
export * from './models/models';
export * from './parsers/parsers';
export * from './formatters/formatters';
export * from './remotes/provider';
export * from './search';
export { RunError } from './shell';
export type GitDiffFilter = 'A' | 'C' | 'D' | 'M' | 'R' | 'T' | 'U' | 'X' | 'B' | '*';
const emptyArray = Object.freeze([]) as unknown as any[];
const emptyObj = Object.freeze({});
const emptyStr = '';
@ -57,19 +49,6 @@ const GitWarnings = {
notAGitCommand: /'.+' is not a git command/i,
};
export const enum GitErrorHandling {
Ignore = 'ignore',
Throw = 'throw',
}
export interface GitCommandOptions extends RunOptions<BufferEncoding | 'buffer' | string> {
configs?: string[];
readonly correlationKey?: string;
errors?: GitErrorHandling;
// Specifies that this command should always be executed locally if possible
local?: boolean;
}
// A map of running git commands -- avoids running duplicate overlaping commands
const pendingCommands = new Map<string, Promise<string | Buffer>>();
@ -1563,7 +1542,3 @@ export namespace Git {
export function isFolderGlob(path: string) {
return paths.basename(path) === '*';
}
export function toFolderGlob(fsPath: string) {
return paths.join(fsPath, '*');
}

src/git/providers/localGitProvider.ts → src/env/node/git/localGitProvider.ts Переглянути файл

@ -16,80 +16,93 @@ import {
WorkspaceFolder,
} from 'vscode';
import { hrtime } from '@env/hrtime';
import type { API as BuiltInGitApi, Repository as BuiltInGitRepository, GitExtension } from '../../@types/vscode.git';
import { configuration } from '../../configuration';
import { BuiltInGitConfiguration, DocumentSchemes, GlyphChars } from '../../constants';
import { Container } from '../../container';
import { LogCorrelationContext, Logger } from '../../logger';
import { Messages } from '../../messages';
import { Arrays, debug, Functions, gate, Iterables, log, Paths, Promises, Strings, Versions } from '../../system';
import { PromiseOrValue } from '../../system/promise';
import { isWindows } from '@env/platform';
import type {
API as BuiltInGitApi,
Repository as BuiltInGitRepository,
GitExtension,
} from '../../../@types/vscode.git';
import { configuration } from '../../../configuration';
import { BuiltInGitConfiguration, DocumentSchemes, GlyphChars } from '../../../constants';
import { Container } from '../../../container';
import { StashApplyError, StashApplyErrorReason } from '../../../git/errors';
import {
CachedBlame,
CachedDiff,
CachedLog,
GitDocumentState,
TrackedDocument,
} from '../../trackers/gitDocumentTracker';
GitProvider,
GitProviderId,
PagedResult,
RepositoryInitWatcher,
ScmRepository,
} from '../../../git/gitProvider';
import { GitProviderService } from '../../../git/gitProviderService';
import { GitUri } from '../../../git/gitUri';
import {
BranchSortOptions,
Git,
GitAuthor,
GitBlame,
GitBlameCommit,
GitBlameLine,
GitBlameLines,
GitBlameParser,
GitBranch,
GitBranchParser,
GitBranchReference,
GitCommitType,
GitContributor,
GitDiff,
GitDiffFilter,
GitDiffHunkLine,
GitDiffParser,
GitDiffShortStat,
GitErrors,
GitFile,
GitLog,
GitLogCommit,
GitLogParser,
GitMergeStatus,
GitRebaseStatus,
GitReference,
GitReflog,
GitRemote,
GitRemoteParser,
GitRevision,
GitStash,
GitStashParser,
GitStatus,
GitStatusFile,
GitStatusParser,
GitTag,
GitTagParser,
GitTree,
GitTreeParser,
GitUser,
isFolderGlob,
maxGitCliLength,
PullRequest,
PullRequestState,
Repository,
RepositoryChange,
RepositoryChangeComparisonMode,
RepositoryChangeEvent,
SearchPattern,
TagSortOptions,
} from '../git';
import { GitProvider, GitProviderId, PagedResult, RepositoryInitWatcher, ScmRepository } from '../gitProvider';
import { GitProviderService } from '../gitProviderService';
import { GitUri } from '../gitUri';
import { findGitPath, GitLocation, InvalidGitConfigError, UnableToFindGitError } from '../locator';
import { GitReflogParser, GitShortLogParser } from '../parsers/parsers';
import { RemoteProvider, RemoteProviderFactory, RemoteProviders, RichRemoteProvider } from '../remotes/factory';
import { fsExists, isWindows } from '../shell';
} from '../../../git/models';
import {
GitBlameParser,
GitBranchParser,
GitDiffParser,
GitLogParser,
GitReflogParser,
GitRemoteParser,
GitShortLogParser,
GitStashParser,
GitStatusParser,
GitTagParser,
GitTreeParser,
} from '../../../git/parsers';
import { RemoteProviderFactory, RemoteProviders } from '../../../git/remotes/factory';
import { RemoteProvider, RichRemoteProvider } from '../../../git/remotes/provider';
import { SearchPattern } from '../../../git/search';
import { LogCorrelationContext, Logger } from '../../../logger';
import { Messages } from '../../../messages';
import { Arrays, debug, Functions, gate, Iterables, log, Paths, Promises, Strings, Versions } from '../../../system';
import { PromiseOrValue } from '../../../system/promise';
import {
CachedBlame,
CachedDiff,
CachedLog,
GitDocumentState,
TrackedDocument,
} from '../../../trackers/gitDocumentTracker';
import { Git, GitErrors, isFolderGlob, maxGitCliLength } from './git';
import { findGitPath, GitLocation, InvalidGitConfigError, UnableToFindGitError } from './locator';
import { fsExists, RunError } from './shell';
const emptyStr = '';
@ -683,7 +696,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
async getBlameForFileContents(uri: GitUri, contents: string): Promise<GitBlame | undefined> {
const cc = Logger.getCorrelationContext();
const key = `blame:${Strings.sha1(contents)}`;
const key = `blame:${Strings.md5(contents)}`;
const doc = await this.container.tracker.getOrAdd(uri);
if (this.useCaching) {
@ -1457,7 +1470,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
): Promise<GitDiff | undefined> {
const cc = Logger.getCorrelationContext();
const key = `diff:${Strings.sha1(contents)}`;
const key = `diff:${Strings.md5(contents)}`;
const doc = await this.container.tracker.getOrAdd(uri);
if (this.useCaching) {
@ -3679,7 +3692,39 @@ export class LocalGitProvider implements GitProvider, Disposable {
stashName: string,
{ deleteAfter }: { deleteAfter?: boolean } = {},
): Promise<void> {
await Git.stash__apply(repoPath, stashName, Boolean(deleteAfter));
try {
await Git.stash__apply(repoPath, stashName, Boolean(deleteAfter));
} catch (ex) {
if (ex instanceof Error) {
const msg: string = ex.message ?? '';
if (msg.includes('Your local changes to the following files would be overwritten by merge')) {
throw new StashApplyError(
'Unable to apply stash. Your working tree changes would be overwritten. Please commit or stash your changes before trying again',
StashApplyErrorReason.WorkingChanges,
ex,
);
}
if (
(msg.includes('Auto-merging') && msg.includes('CONFLICT')) ||
(ex instanceof RunError &&
((ex.stdout.includes('Auto-merging') && ex.stdout.includes('CONFLICT')) ||
ex.stdout.includes('needs merge')))
) {
void window.showInformationMessage('Stash applied with conflicts');
return;
}
throw new StashApplyError(
`Unable to apply stash \u2014 ${msg.trim().replace(/\n+?/g, '; ')}`,
undefined,
ex,
);
}
throw new StashApplyError(`Unable to apply stash \u2014 ${String(ex)}`, undefined, ex);
}
}
@log()

src/git/locator.ts → src/env/node/git/locator.ts Переглянути файл

@ -1,8 +1,8 @@
'use strict';
import * as paths from 'path';
import { GlyphChars } from '../constants';
import { LogLevel } from '../logger';
import { Stopwatch } from '../system';
import { GlyphChars } from '../../../constants';
import { LogLevel } from '../../../logger';
import { Stopwatch } from '../../../system';
import { findExecutable, run } from './shell';
export class UnableToFindGitError extends Error {

src/git/shell.ts → src/env/node/git/shell.ts Переглянути файл

@ -3,7 +3,7 @@ import { ExecException, execFile } from 'child_process';
import * as fs from 'fs';
import * as paths from 'path';
import * as iconv from 'iconv-lite';
import { Logger } from '../logger';
import { Logger } from '../../../logger';
export const isWindows = process.platform === 'win32';

+ 4
- 0
src/env/node/platform.ts Переглянути файл

@ -0,0 +1,4 @@
import { env, UIKind } from 'vscode';
export const isWeb = env.uiKind === UIKind.Web;
export const isWindows = process.platform === 'win32';

+ 2
- 2
src/extension.ts Переглянути файл

@ -1,14 +1,14 @@
'use strict';
import { version as codeVersion, commands, env, ExtensionContext, extensions, window, workspace } from 'vscode';
import type { CreatePullRequestActionContext, GitLensApi, OpenPullRequestActionContext } from '../src/api/gitlens';
import { Api } from './api/api';
import type { CreatePullRequestActionContext, GitLensApi, OpenPullRequestActionContext } from './api/gitlens';
import { Commands, executeCommand, OpenPullRequestOnRemoteCommandArgs, registerCommands } from './commands';
import { CreatePullRequestOnRemoteCommandArgs } from './commands/createPullRequestOnRemote';
import { configuration, Configuration, OutputLevel } from './configuration';
import { ContextKeys, GlobalState, setContext, SyncedState } from './constants';
import { Container } from './container';
import { GitBranch, GitCommit } from './git/git';
import { GitUri } from './git/gitUri';
import { GitBranch, GitCommit } from './git/models';
import { Logger, LogLevel } from './logger';
import { Messages } from './messages';
import { registerPartnerActionRunners } from './partners';

+ 23
- 0
src/git/commandOptions.ts Переглянути файл

@ -0,0 +1,23 @@
'use strict';
export const enum GitErrorHandling {
Throw = 0,
Ignore = 1,
}
export interface GitCommandOptions {
// extends RunOptions<BufferEncoding | 'buffer' | string> {
configs?: string[];
readonly correlationKey?: string;
errors?: GitErrorHandling;
// Specifies that this command should always be executed locally if possible
local?: boolean;
// Below options comes from RunOptions<BufferEncoding | 'buffer' | string>
cwd?: string;
readonly env?: Record<string, any>;
readonly encoding?: BufferEncoding | 'buffer' | string;
readonly maxBuffer?: number;
readonly stdin?: string | Buffer;
readonly stdinEncoding?: string;
}

+ 17
- 0
src/git/errors.ts Переглянути файл

@ -1,3 +1,4 @@
'use strict';
import { Uri } from 'vscode';
import { GitProviderId, GitProviderService } from './gitProviderService';
@ -15,3 +16,19 @@ export class ProviderNotFoundError extends Error {
Error.captureStackTrace?.(this, ProviderNotFoundError);
}
}
export const enum StashApplyErrorReason {
WorkingChanges = 1,
}
export class StashApplyError extends Error {
constructor(
message: string,
public readonly reason: StashApplyErrorReason | undefined,
public readonly original?: Error,
) {
super(message);
Error.captureStackTrace?.(this, StashApplyError);
}
}

+ 4
- 0
src/git/formatters.ts Переглянути файл

@ -0,0 +1,4 @@
'use strict';
export * from './formatters/commitFormatter';
export * from './formatters/statusFormatter';

+ 2
- 9
src/git/formatters/commitFormatter.ts Переглянути файл

@ -18,16 +18,9 @@ import { Container } from '../../container';
import { emojify } from '../../emojis';
import { Iterables, Promises, Strings } from '../../system';
import { ContactPresence } from '../../vsls/vsls';
import {
GitCommit,
GitLogCommit,
GitRemote,
GitRevision,
IssueOrPullRequest,
PullRequest,
RemoteProvider,
} from '../git';
import { GitUri } from '../gitUri';
import { GitCommit, GitLogCommit, GitRemote, GitRevision, IssueOrPullRequest, PullRequest } from '../models';
import { RemoteProvider } from '../remotes/provider';
import { FormatOptions, Formatter } from './formatter';
const emptyStr = '';

+ 0
- 4
src/git/formatters/formatters.ts Переглянути файл

@ -1,4 +0,0 @@
'use strict';
export * from './commitFormatter';
export * from './statusFormatter';

+ 1
- 1
src/git/fsProvider.ts Переглянути файл

@ -14,9 +14,9 @@ import {
} from 'vscode';
import { DocumentSchemes } from '../constants';
import { Container } from '../container';
import { GitRevision, GitTree } from '../git/git';
import { GitUri } from '../git/gitUri';
import { debug, Iterables, Strings, TernarySearchTree } from '../system';
import { GitRevision, GitTree } from './models';
const emptyArray = new Uint8Array(0);

+ 3
- 4
src/git/gitProvider.ts Переглянути файл

@ -1,5 +1,6 @@
import { Disposable, Event, Range, TextEditor, Uri, WorkspaceFolder } from 'vscode';
import { Commit, InputBox } from '../@types/vscode.git';
import { GitUri } from './gitUri';
import {
BranchSortOptions,
GitBlame,
@ -25,14 +26,12 @@ import {
GitTag,
GitTree,
GitUser,
RemoteProvider,
Repository,
RepositoryChangeEvent,
RichRemoteProvider,
TagSortOptions,
} from './git';
import { GitUri } from './gitUri';
} from './models';
import { RemoteProviders } from './remotes/factory';
import { RemoteProvider, RichRemoteProvider } from './remotes/provider';
import { SearchPattern } from './search';
export const enum GitProviderId {

+ 6
- 6
src/git/gitProviderService.ts Переглянути файл

@ -31,8 +31,9 @@ import { Arrays, debug, gate, Iterables, log, Paths, Promises, Strings } from '.
import { PromiseOrValue } from '../system/promise';
import { vslsUriPrefixRegex } from '../vsls/vsls';
import { ProviderNotFoundError } from './errors';
import { GitProvider, GitProviderDescriptor, GitProviderId, PagedResult, ScmRepository } from './gitProvider';
import { GitUri } from './gitUri';
import {
Authentication,
BranchDateFormatting,
BranchSortOptions,
CommitDateFormatting,
@ -68,12 +69,11 @@ import {
RepositoryChange,
RepositoryChangeComparisonMode,
RepositoryChangeEvent,
SearchPattern,
TagSortOptions,
} from './git';
import { GitProvider, GitProviderDescriptor, GitProviderId, PagedResult, ScmRepository } from './gitProvider';
import { GitUri } from './gitUri';
import { RemoteProvider, RemoteProviders, RichRemoteProvider } from './remotes/factory';
} from './models';
import { RemoteProviders } from './remotes/factory';
import { Authentication, RemoteProvider, RichRemoteProvider } from './remotes/provider';
import { SearchPattern } from './search';
export { type GitProviderDescriptor, GitProviderId };

+ 1
- 1
src/git/gitUri.ts Переглянути файл

@ -4,9 +4,9 @@ import { Uri } from 'vscode';
import { UriComparer } from '../comparers';
import { DocumentSchemes } from '../constants';
import { Container } from '../container';
import { GitCommit, GitFile, GitRevision } from '../git/git';
import { Logger } from '../logger';
import { debug, memoize, Strings } from '../system';
import { GitCommit, GitFile, GitRevision } from './models';
const emptyStr = '';
const slash = '/';

+ 28
- 0
src/git/models.ts Переглянути файл

@ -0,0 +1,28 @@
'use strict';
export * from './models/author';
export * from './models/blame';
export * from './models/blameCommit';
export * from './models/branch';
export * from './models/commit';
export * from './models/contributor';
export * from './models/defaultBranch';
export * from './models/diff';
export * from './models/file';
export * from './models/issue';
export * from './models/log';
export * from './models/logCommit';
export * from './models/merge';
export * from './models/pullRequest';
export * from './models/reference';
export * from './models/rebase';
export * from './models/reflog';
export * from './models/remote';
export * from './models/remoteProvider';
export * from './models/repository';
export * from './models/shortlog';
export * from './models/stash';
export * from './models/stashCommit';
export * from './models/status';
export * from './models/tag';
export * from './models/tree';
export * from './models/user';

+ 3
- 2
src/git/models/branch.ts Переглянути файл

@ -3,8 +3,9 @@ import { BranchSorting, configuration, DateStyle } from '../../configuration';
import { Starred, WorkspaceState } from '../../constants';
import { Container } from '../../container';
import { Dates, debug, memoize, Strings } from '../../system';
import { GitRemote, GitRevision } from '../git';
import { GitBranchReference, GitReference, PullRequest, PullRequestState } from './models';
import { GitBranchReference, GitReference, GitRevision } from '../models';
import { PullRequest, PullRequestState } from './pullRequest';
import { GitRemote } from './remote';
import { GitStatus } from './status';
const whitespaceRegex = /\s/;

+ 2
- 2
src/git/models/commit.ts Переглянути файл

@ -4,9 +4,9 @@ import { getAvatarUri } from '../../avatars';
import { configuration, DateSource, DateStyle, GravatarDefaultStyle } from '../../configuration';
import { Container } from '../../container';
import { Dates, memoize } from '../../system';
import { CommitFormatter } from '../formatters/formatters';
import { CommitFormatter } from '../formatters';
import { GitUri } from '../gitUri';
import { GitReference, GitRevision, GitRevisionReference, PullRequest } from './models';
import { GitReference, GitRevision, GitRevisionReference, PullRequest } from '../models';
export interface GitAuthor {
name: string;

+ 2
- 0
src/git/models/diff.ts Переглянути файл

@ -53,3 +53,5 @@ export interface GitDiffShortStat {
readonly insertions: number;
readonly deletions: number;
}
export type GitDiffFilter = 'A' | 'C' | 'D' | 'M' | 'R' | 'T' | 'U' | 'X' | 'B' | '*';

+ 1
- 1
src/git/models/logCommit.ts Переглянути файл

@ -2,9 +2,9 @@
import { Uri } from 'vscode';
import { memoize, Strings } from '../../system';
import { GitUri } from '../gitUri';
import { GitReference } from '../models';
import { GitCommit, GitCommitType } from './commit';
import { GitFile, GitFileStatus } from './file';
import { GitReference } from './models';
const emptyStats = Object.freeze({
added: 0,

+ 1
- 1
src/git/models/merge.ts Переглянути файл

@ -1,5 +1,5 @@
'use strict';
import { GitBranchReference, GitRevisionReference } from './models';
import { GitBranchReference, GitRevisionReference } from '../models';
export interface GitMergeStatus {
type: 'merge';

+ 1
- 1
src/git/models/rebase.ts Переглянути файл

@ -1,5 +1,5 @@
'use strict';
import { GitBranchReference, GitRevisionReference } from './models';
import { GitBranchReference, GitRevisionReference } from '../models';
export interface GitRebaseStatus {
type: 'rebase';

src/git/models/models.ts → src/git/models/reference.ts Переглянути файл

@ -339,30 +339,3 @@ export namespace GitReference {
}
}
}
export * from './author';
export * from './blame';
export * from './blameCommit';
export * from './branch';
export * from './commit';
export * from './contributor';
export * from './defaultBranch';
export * from './diff';
export * from './file';
export * from './issue';
export * from './log';
export * from './logCommit';
export * from './merge';
export * from './pullRequest';
export * from './rebase';
export * from './reflog';
export * from './remote';
export * from './remoteProvider';
export * from './repository';
export * from './shortlog';
export * from './stash';
export * from './stashCommit';
export * from './status';
export * from './tag';
export * from './tree';
export * from './user';

+ 1
- 1
src/git/models/reflog.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { DateStyle } from '../../config';
import { Dates, memoize } from '../../system';
import { CommitDateFormatting, GitRevision } from '../git';
import { CommitDateFormatting, GitRevision } from '../models';
export interface GitReflog {
readonly repoPath: string;

+ 1
- 1
src/git/models/remote.ts Переглянути файл

@ -2,7 +2,7 @@
import { WorkspaceState } from '../../constants';
import { Container } from '../../container';
import { Strings } from '../../system';
import { RemoteProvider, RichRemoteProvider } from '../remotes/factory';
import { RemoteProvider, RichRemoteProvider } from '../remotes/provider';
export const enum GitRemoteType {
Fetch = 'fetch',

+ 15
- 22
src/git/models/repository.ts Переглянути файл

@ -22,30 +22,23 @@ import { Logger, LogLevel } from '../../logger';
import { Messages } from '../../messages';
import { Arrays, Dates, debug, Functions, gate, Iterables, log, logName } from '../../system';
import { runGitCommandInTerminal } from '../../terminal';
import {
GitBranch,
GitContributor,
GitDiffShortStat,
GitRemote,
GitStash,
GitStatus,
GitTag,
SearchPattern,
} from '../git';
import { GitProviderDescriptor } from '../gitProvider';
import { GitUri } from '../gitUri';
import { RemoteProviderFactory, RemoteProviders, RichRemoteProvider } from '../remotes/factory';
import {
BranchSortOptions,
GitBranchReference,
GitLog,
GitLogCommit,
GitMergeStatus,
GitRebaseStatus,
GitReference,
GitTagReference,
TagSortOptions,
} from './models';
import { RemoteProviderFactory, RemoteProviders } from '../remotes/factory';
import { RichRemoteProvider } from '../remotes/provider';
import { SearchPattern } from '../search';
import { BranchSortOptions, GitBranch } from './branch';
import { GitContributor } from './contributor';
import { GitDiffShortStat } from './diff';
import { GitLog } from './log';
import { GitLogCommit } from './logCommit';
import { GitMergeStatus } from './merge';
import { GitRebaseStatus } from './rebase';
import { GitBranchReference, GitReference, GitTagReference } from './reference';
import { GitRemote } from './remote';
import { GitStash } from './stash';
import { GitStatus } from './status';
import { GitTag, TagSortOptions } from './tag';
export const enum RepositoryChange {
// FileSystem = 'filesystem',

+ 1
- 1
src/git/models/stashCommit.ts Переглянути файл

@ -1,10 +1,10 @@
'use strict';
import { Container } from '../../container';
import { gate, memoize } from '../../system';
import { GitReference } from '../models';
import { GitCommitType } from './commit';
import { GitFile, GitFileWorkingTreeStatus } from './file';
import { GitLogCommit } from './logCommit';
import { GitReference } from './models';
const stashNumberRegex = /stash@{(\d+)}/;

+ 1
- 1
src/git/models/status.ts Переглянути файл

@ -4,9 +4,9 @@ import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { memoize, Strings } from '../../system';
import { GitUri } from '../gitUri';
import { GitCommitType, GitLogCommit, GitRemote, GitRevision, GitUser } from '../models';
import { GitBranch, GitTrackingState } from './branch';
import { GitFile, GitFileConflictStatus, GitFileIndexStatus, GitFileStatus, GitFileWorkingTreeStatus } from './file';
import { GitCommitType, GitLogCommit, GitRemote, GitRevision, GitUser } from './models';
export interface ComputedWorkingTreeGitStatus {
staged: number;

+ 1
- 1
src/git/models/tag.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import { configuration, DateStyle, TagSorting } from '../../configuration';
import { Dates, memoize, Strings } from '../../system';
import { GitReference, GitTagReference } from './models';
import { GitReference, GitTagReference } from '../models';
export const TagDateFormatting = {
dateFormat: undefined! as string | null,

+ 13
- 0
src/git/parsers.ts Переглянути файл

@ -0,0 +1,13 @@
'use strict';
export * from './parsers/blameParser';
export * from './parsers/branchParser';
export * from './parsers/diffParser';
export * from './parsers/logParser';
export * from './parsers/reflogParser';
export * from './parsers/remoteParser';
export * from './parsers/shortlogParser';
export * from './parsers/stashParser';
export * from './parsers/statusParser';
export * from './parsers/tagParser';
export * from './parsers/treeParser';

+ 1
- 1
src/git/parsers/blameParser.ts Переглянути файл

@ -1,7 +1,7 @@
'use strict';
import * as paths from 'path';
import { debug, Strings } from '../../system';
import { GitAuthor, GitBlame, GitBlameCommit, GitCommitLine, GitRevision, GitUser } from '../git';
import { GitAuthor, GitBlame, GitBlameCommit, GitCommitLine, GitRevision, GitUser } from '../models';
const emptyStr = '';
const slash = '/';

+ 1
- 1
src/git/parsers/logParser.ts Переглянути файл

@ -12,7 +12,7 @@ import {
GitLogCommitLine,
GitRevision,
GitUser,
} from '../git';
} from '../models';
const emptyEntry: LogEntry = {};
const emptyStr = '';

+ 0
- 13
src/git/parsers/parsers.ts Переглянути файл

@ -1,13 +0,0 @@
'use strict';
export * from './blameParser';
export * from './branchParser';
export * from './diffParser';
export * from './logParser';
export * from './reflogParser';
export * from './remoteParser';
export * from './shortlogParser';
export * from './stashParser';
export * from './statusParser';
export * from './tagParser';
export * from './treeParser';

Деякі файли не було показано, через те що забагато файлів було змінено

Завантаження…
Відмінити
Зберегти