ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / git / src / model.ts 1226 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
import { workspace, WorkspaceFoldersChangeEvent, Uri, window, Event, EventEmitter, QuickPickItem, Disposable, SourceControl, SourceControlResourceGroup, TextEditor, Memento, commands, LogOutputChannel, l10n, ProgressLocation, WorkspaceFolder, ThemeIcon, ResourceTrustRequestOptions } from 'vscode' ;
import TelemetryReporter from '@vscode/extension-telemetry' ;
import { IRepositoryResolver, Repository, RepositoryState } from './repository' ;
import { memoize, sequentialize, debounce } from './decorators' ;
dispose anyEvent filterEvent isDescendant Limiter pathEquals toDisposable eventToPromise
Git
path
fs
fromGitUri
APIState State CredentialsProvider PushErrorHandler PublishEvent RemoteSourcePublisher PostCommitCommandsProvider BranchProtectionProvider SourceControlHistoryItemDetailsProvider
Askpass
IPushErrorHandlerRegistry
ApiRepository
IRemoteSourcePublisherRegistry
IPostCommitCommandsProviderRegistry
IBranchProtectionProviderRegistry
ISourceControlHistoryItemDetailsProviderRegistry
RepositoryCache
path repository root
repository headLabel repository syncLabel
l l
ThemeIcon
repository kind
repository Repository index
repository Repository
uri Uri
repository Repository
uri Uri
repository Repository
_repositories Set
_repositories
workspaceState Memento
_repositories workspaceState
repository
_repositories repository
repository
result _repositories repository
result
result
repository
_repositories repository
workspaceState _repositories
commands _repositories size
_repositories
_repositories
globalState Memento
repository
_repositories repository
repository
result _repositories repository
result
result
repository
_repositories repository
repository
globalState
repository
commands _repositories size
_repositories
_repositories
repository path
_repositories repository path
repository
result _repositories repository
result
result
repository
_repositories repository
repository
_repositories repository
commands _repositories size
IBranchProtectionProviderRegistry IRemoteSourcePublisherRegistry IPostCommitCommandsProviderRegistry IPushErrorHandlerRegistry ISourceControlHistoryItemDetailsProviderRegistry
_onDidOpenRepository
onDidOpenRepository Event Repository _onDidOpenRepository event
_onDidCloseRepository
onDidCloseRepository Event Repository _onDidCloseRepository event
_onDidChangeRepository
onDidChangeRepository Event ModelChangeEvent _onDidChangeRepository event
_onDidChangeOriginalResource
onDidChangeOriginalResource Event OriginalResourceChangeEvent _onDidChangeOriginalResource event
openRepositories OpenRepository
Repository openRepositories r r repository
possibleGitRepositoryPaths
_onDidChangeState
onDidChangeState _onDidChangeState event
_onDidPublish
onDidPublish _onDidPublish event
repository Repository branch
_onDidPublish repository repository branch branch
_state State
State _state
state State
_state state
_onDidChangeState state
commands state
_state
onDidChangeState s s Event
remoteSourcePublishers
_onDidAddRemoteSourcePublisher
onDidAddRemoteSourcePublisher _onDidAddRemoteSourcePublisher event
_onDidRemoveRemoteSourcePublisher
onDidRemoveRemoteSourcePublisher _onDidRemoveRemoteSourcePublisher event
postCommitCommandsProviders
_onDidChangePostCommitCommandsProviders
onDidChangePostCommitCommandsProviders _onDidChangePostCommitCommandsProviders event
branchProtectionProviders
_onDidChangeBranchProtectionProviders
onDidChangeBranchProtectionProviders _onDidChangeBranchProtectionProviders event
pushErrorHandlers
historyItemDetailsProviders
_unsafeRepositoriesManager UnsafeRepositoriesManager
_unsafeRepositoriesManager repositories
_parentRepositoriesManager ParentRepositoriesManager
_parentRepositoriesManager repositories
_closedRepositoriesManager ClosedRepositoriesManager
_closedRepositoriesManager repositories
_workspaceFolders
_repositoryCache RepositoryCache
RepositoryCache
_repositoryCache
_initialStatusLimiter
disposables Disposable
git Git askpass Askpass globalState Memento workspaceState Memento logger LogOutputChannel telemetryReporter TelemetryReporter
_closedRepositoriesManager workspaceState
_parentRepositoriesManager globalState
_unsafeRepositoriesManager
workspace onDidChangeWorkspaceFolders disposables
workspace onDidChangeWorkspaceTrustedFolders disposables
window onDidChangeVisibleTextEditors disposables
window onDidChangeActiveTextEditor disposables
workspace onDidChangeConfiguration disposables
fsWatcher workspace
disposables fsWatcher
onWorkspaceChange fsWatcher onDidChange fsWatcher onDidCreate fsWatcher onDidDelete
onGitRepositoryChange onWorkspaceChange uri uri path
onPossibleGitRepositoryChange onGitRepositoryChange uri uri
onPossibleGitRepositoryChange disposables
_repositoryCache globalState logger
logger
config workspace
autoRepositoryDetection config
parentRepositoryConfig config
logger
added workspace workspaceFolders removed
window visibleTextEditors
config
window location ProgressLocation SourceControl initialScanFn
parentRepositories length
parentRepositoryConfig
unsafeRepositories length
telemetryReporter autoRepositoryDetection autoRepositoryDetection repositoryCount openRepositories length
logger
config workspace
autoRepositoryDetection config
autoRepositoryDetection autoRepositoryDetection
workspace workspaceFolders folder
root folder uri fsPath
logger
repositoryScanMaxDepth workspace isTrusted workspace folder uri config
repositoryScanIgnoredFolders workspace isTrusted workspace folder uri config
subfolders root repositoryScanMaxDepth repositoryScanIgnoredFolders
scanPaths workspace isTrusted workspace folder uri config
logger
scanPath scanPaths
scanPath
logger
path scanPath
notSupportedMessage l10n
logger
notSupportedMessage
subfolders path root scanPath
logger
subfolders f f
err
logger
workspaceFolder maxDepth repositoryScanIgnoredFolders
result
foldersToTravers path workspaceFolder depth
foldersToTravers length
currentFolder foldersToTravers
children fs Dirent
children fs promises currentFolder path withFileTypes
currentFolder depth
result currentFolder path
err
logger
currentFolder depth maxDepth maxDepth
childrenFolders children
dirent
dirent dirent name
repositoryScanIgnoredFolders f dirent name f
dirent path currentFolder path dirent name
foldersToTravers childrenFolders folder
path folder depth currentFolder depth
result
uri Uri
config workspace
autoRepositoryDetection config
autoRepositoryDetection
uri fsPath
path
possibleGitRepositoryPaths path
path possibleGitRepositoryPaths
path
possibleGitRepositoryPaths
added removed WorkspaceFoldersChangeEvent
possibleRepositoryFolders added
folder folder uri
activeRepositoriesList window visibleTextEditors
editor editor document uri
repository repository Repository
activeRepositories activeRepositoriesList
openRepositoriesToDispose removed
folder folder uri
r r
r activeRepositories r repository
r workspace workspaceFolders f f uri fsPath r repository root OpenRepository
openRepositoriesToDispose r r
logger
possibleRepositoryFolders p p uri fsPath
err
logger
openRepositoriesToDispose OpenRepository
openRepository openRepositories
dotGitPath openRepository repository dotGit commonPath openRepository repository dotGit path
isTrusted workspace Uri path dotGitPath
isTrusted
openRepositoriesToDispose openRepository
logger
openRepositoriesToDispose r r
err
logger
possibleRepositoryFolders workspace workspaceFolders
folder workspace folder uri
folder folder uri
openRepositoriesToDispose openRepositories
repository repository root Uri repository repository root
root workspace root
repository repository
logger
possibleRepositoryFolders p p uri fsPath
openRepositoriesToDispose r r
editors TextEditor
workspace isTrusted
logger
config workspace
autoRepositoryDetection config
autoRepositoryDetection autoRepositoryDetection
editors editor
uri editor document uri
uri scheme
repository uri
repository
logger
logger
path uri fsPath
err
logger
textEditor window activeTextEditor
textEditor
commands
commands
commands
repository textEditor document uri
repository
commands
commands
commands
indexResource repository indexGroup resourceStates
resource resource resourceUri fsPath textEditor document uri fsPath
workingTreeResource repository workingTreeGroup resourceStates
resource resource resourceUri fsPath textEditor document uri fsPath
mergeChangesResource repository mergeGroup resourceStates
resource resource resourceUri fsPath textEditor document uri fsPath
hasMergeConflicts mergeChangesResource textEditor document
commands indexResource
commands workingTreeResource
commands hasMergeConflicts
repoPath openIfClosed openIfParent
logger
existingRepository repoPath
existingRepository
logger
config workspace Uri repoPath
enabled config
enabled
logger
repositoryRoot unsafeRepositoryMatch repoPath
logger
existingRepository repositoryRoot
existingRepository
logger
repositoryRoot
logger
parentRepositoryConfig config
parentRepositoryConfig globalState
isRepositoryOutsideWorkspace repositoryRoot
openIfParent isRepositoryOutsideWorkspace
logger
_parentRepositoriesManager repositoryRoot
state parentRepositoryConfig
_parentRepositoriesManager repositoryRoot
unsafeRepositoryMatch unsafeRepositoryMatch length
logger
_state _unsafeRepositoriesManager repositoryRoot
_unsafeRepositoriesManager repositoryRoot unsafeRepositoryMatch
openIfClosed _closedRepositoriesManager repositoryRoot
logger
dotGit repositoryRootRealPath git repositoryRoot repositoryRoot
dotGitPath dotGit commonPath dotGit path
result workspace
message l10n
uri Uri path dotGitPath
satisfies ResourceTrustRequestOptions
result
logger
gitRepository git repositoryRoot repositoryRootRealPath dotGit logger
repository gitRepository globalState logger telemetryReporter _repositoryCache
repository
_closedRepositoriesManager repository root
logger
logger
logger
_initialStatusLimiter repository
_repositoryCache repository remotes repository root
err
logger
repoPath
_parentRepositoriesManager repoPath
repoPath
repoPath repositoryRoot unsafeRepositoryMatch RegExpMatchArray
rawRoot git repoPath
repositoryRoot Uri rawRoot fsPath unsafeRepositoryMatch
err
unsafeRepositoryMatch err stderr
unsafeRepositoryMatch unsafeRepositoryMatch length
repositoryRoot path unsafeRepositoryMatch unsafeRepositoryMatch
err
repositoryRoot
repositoryRootRealPath fs promises repositoryRoot
repositoryRoot repositoryRootRealPath repositoryRootRealPath
err
logger
repositoryRoot
config workspace
ignoredRepos config
ignoredRepo ignoredRepos
path ignoredRepo
ignoredRepo repositoryRoot
folder workspace workspaceFolders
path folder uri fsPath ignoredRepo repositoryRoot
repository Repository
logger
onDidDisappearRepository repository onDidChangeState state state RepositoryState Disposed
disappearListener
disposeParentListener repository sourceControl
changeListener repository uri _onDidChangeRepository repository uri
originalResourceChangeListener repository uri _onDidChangeOriginalResource repository uri
shouldDetectSubmodules workspace
Uri repository root
submodulesLimit workspace
Uri repository root
shouldDetectWorktrees workspace
Uri repository root
worktreesLimit workspace
Uri repository root
shouldDetectSubmodules
logger
repository submodules length submodulesLimit
window l10n path repository root repository submodules length
statusListener
repository submodules
submodulesLimit
r path repository root r path
p
logger
p
shouldDetectWorktrees
logger
repository kind
logger
repository worktrees length worktreesLimit
window l10n path repository root repository worktrees length
statusListener
repository worktrees
worktreesLimit
w
logger
w path
mergeChanges Uri
repository openRepositories
state repository mergeGroup resourceStates
mergeChanges state resourceUri
commands mergeChanges
statusListener repository
operationInProgress
repository openRepositories
repository operations
operationInProgress
commands operationInProgress
operationEvent repository onDidRunOperation Event repository onRunOperation Event
operationListener
disappearListener
disposeParentListener
changeListener
originalResourceChangeListener
statusListener
operationListener
repository
openRepositories openRepositories e e openRepository
_onDidCloseRepository repository
openRepository repository dispose
openRepositories openRepository
_onDidOpenRepository repository
repository Repository
openRepository repository
openRepository
logger
_closedRepositoriesManager openRepository repository root
_repositoryCache repository remotes repository root
openRepository
repositoryFilter Repository
openRepositories length
l10n
repositories openRepositories
r r repository isHidden
repositoryFilter repositoryFilter r repository kind
repositories length
l10n
repositories length
repositories repository
active window activeTextEditor
picks repositories e index e repository index
repository active active document fileName
index picks pick pick repository repository
index
picks picks index
placeHolder l10n
pick window picks placeHolder
pick pick repository
hint SourceControl SourceControlResourceGroup Uri Repository
liveRepository hint
liveRepository liveRepository repository
repoPath Repository
openRepository openRepositories
r r repository root repoPath
openRepository
openRepository repository
repoPathRealPath fs promises repoPath encoding
openRepositoryRealPath openRepositories
r r repository rootRealPath r repository root repoPathRealPath
openRepositoryRealPath repository
err
logger
hint SourceControl SourceControlResourceGroup Repository Uri OpenRepository
hint
hint
openRepositories r r repository hint
hint
hint hint rootUri
hint
hint Uri hint
hint
resourcePath
hint scheme
resourcePath hint path
resourcePath hint fsPath
outer
liveRepository openRepositories a b b repository root length a repository root length
liveRepository repository root resourcePath
submodule liveRepository repository submodules
submoduleRoot path liveRepository repository root submodule path
submoduleRoot resourcePath
outer
liveRepository
liveRepository openRepositories
repository liveRepository repository
hint repository sourceControl
liveRepository
hint repository mergeGroup hint repository indexGroup hint repository workingTreeGroup hint repository untrackedGroup
liveRepository
submoduleUri Uri Repository
repository repositories
submodule repository submodules
submodulePath path repository root submodule path
submodulePath submoduleUri fsPath
repository
publisher RemoteSourcePublisher Disposable
remoteSourcePublishers publisher
_onDidAddRemoteSourcePublisher publisher
remoteSourcePublishers publisher
_onDidRemoveRemoteSourcePublisher publisher
RemoteSourcePublisher
remoteSourcePublishers
root Uri provider BranchProtectionProvider Disposable
providerDisposables Disposable
branchProtectionProviders root branchProtectionProviders root provider
providerDisposables provider uri _onDidChangeBranchProtectionProviders uri
_onDidChangeBranchProtectionProviders root
providers branchProtectionProviders root
providers providers provider
providers provider
branchProtectionProviders root providers
_onDidChangeBranchProtectionProviders root
providerDisposables
root Uri BranchProtectionProvider
branchProtectionProviders root
provider PostCommitCommandsProvider Disposable
postCommitCommandsProviders provider
_onDidChangePostCommitCommandsProviders
postCommitCommandsProviders provider
_onDidChangePostCommitCommandsProviders
PostCommitCommandsProvider
postCommitCommandsProviders
provider CredentialsProvider Disposable
askpass provider
handler PushErrorHandler Disposable
pushErrorHandlers handler
pushErrorHandlers handler
PushErrorHandler
pushErrorHandlers
provider SourceControlHistoryItemDetailsProvider Disposable
historyItemDetailsProviders provider
historyItemDetailsProviders provider
SourceControlHistoryItemDetailsProvider
historyItemDetailsProviders
repository
_unsafeRepositoriesManager repository
repository
_unsafeRepositoriesManager repository
repositoryPath
workspace workspaceFolders
workspace isAgentSessionsWorkspace
workspaceFolders workspace workspaceFolders
folder folder uri scheme
workspaceFolders length
worktreePaths repositories r r worktrees w w path
worktreePaths p p repositoryPath
workspaceFolderPaths
workspaceFolders folder folder uri fsPath
workspaceFolders folder folder
workspaceFolderPaths folder folder folder repositoryPath folder repositoryPath
workspaceFolder WorkspaceFolder
result _workspaceFolders workspaceFolder uri fsPath
result
result fs promises workspaceFolder uri fsPath encoding
_workspaceFolders workspaceFolder uri fsPath result
err
logger
result
message parentRepositories length
l10n
l10n
yes l10n
always l10n
l10n
choice window message yes always
choice yes
commands
choice always choice
config workspace
config choice always
choice always
parentRepository parentRepositories
parentRepository
repositories length
message unsafeRepositories length
l10n
l10n
manageUnsafeRepositories l10n
learnMore l10n
choice window message manageUnsafeRepositories learnMore
choice manageUnsafeRepositories
commands
choice learnMore
commands Uri
openRepositories openRepositories
openRepositories r r
openRepositories
possibleGitRepositoryPaths
disposables disposables
import
{
,
,
,
,
,
,
,
}
from
'./util'
;
import
{
}
from
'./git'
;
import
*
as
from
'path'
;
import
*
as
from
'fs'
;
import
{
}
from
'./uri'
;
import
type
{
as
,
,
,
,
,
,
,
}
from
'./api/git'
;
import
{
}
from
'./askpass'
;
import
{
}
from
'./pushError'
;
import
{
}
from
'./api/api1'
;
import
{
}
from
'./remotePublisher'
;
import
{
}
from
'./postCommitCommands'
;
import
{
}
from
'./branchProtection'
;
import
{
}
from
'./historyItemDetailsProvider'
;
import
{
}
from
'./repositoryCache'
;
class
RepositoryPick
implements
QuickPickItem
{
@ memoize
get
label
(
)
:
string
{
return
.
basename
(
this
.
.
)
;
}
@ memoize
get
description
(
)
:
string
{
return
[
this
.
.
,
this
.
.
]
.
filter
(
=>
!
!
)
.
join
(
' '
)
;
}
@ memoize
get
iconPath
(
)
:
{
switch
(
this
.
.
)
{
case
'submodule'
:
return
new
ThemeIcon
(
'archive'
)
;
case
'worktree'
:
return
new
ThemeIcon
(
'list-tree'
)
;
default
:
return
new
ThemeIcon
(
'repo'
)
;
}
}
constructor
(
public
readonly
:
,
public
readonly
:
number
)
{
}
}
export
interface
ModelChangeEvent
{
:
;
:
;
}
export
interface
OriginalResourceChangeEvent
{
:
;
:
;
}
interface
OpenRepository
extends
Disposable
{
:
;
}
class
ClosedRepositoriesManager
{
private
:
<
string
>
;
get
repositories
(
)
:
string
[
]
{
return
[
...
this
.
.
values
(
)
]
;
}
constructor
(
private
readonly
:
)
{
this
.
=
new
Set< string >
(
.
get < string [ ] >
(
'closedRepositories'
,
[
]
)
)
;
this
.
onDidChangeRepositories
(
)
;
}
addRepository
(
:
string
)
:
void
{
this
.
.
add
(
)
;
this
.
onDidChangeRepositories
(
)
;
}
deleteRepository
(
:
string
)
:
boolean
{
const
=
this
.
.
delete
(
)
;
if
(
)
{
this
.
onDidChangeRepositories
(
)
;
}
return
;
}
isRepositoryClosed
(
:
string
)
:
boolean
{
return
this
.
.
has
(
)
;
}
private
onDidChangeRepositories
(
)
:
void
{
this
.
.
update
(
'closedRepositories'
,
[
...
this
.
.
values
(
)
]
)
;
.
executeCommand
(
'setContext'
,
'git.closedRepositoryCount'
,
this
.
.
)
;
}
}
class
ParentRepositoriesManager
{
private
=
new
Set< string >
;
get
repositories
(
)
:
string
[
]
{
return
[
...
this
.
.
values
(
)
]
;
}
constructor
(
private
readonly
:
)
{
this
.
onDidChangeRepositories
(
)
;
}
addRepository
(
:
string
)
:
void
{
this
.
.
add
(
)
;
this
.
onDidChangeRepositories
(
)
;
}
deleteRepository
(
:
string
)
:
boolean
{
const
=
this
.
.
delete
(
)
;
if
(
)
{
this
.
onDidChangeRepositories
(
)
;
}
return
;
}
hasRepository
(
:
string
)
:
boolean
{
return
this
.
.
has
(
)
;
}
openRepository
(
:
string
)
:
void
{
this
.
.
update
(
` parentRepository: ${ repository} `
,
true
)
;
this
.
deleteRepository
(
)
;
}
private
onDidChangeRepositories
(
)
:
void
{
.
executeCommand
(
'setContext'
,
'git.parentRepositoryCount'
,
this
.
.
)
;
}
}
class
UnsafeRepositoriesManager
{
private
=
new
Map< string , string >
(
)
;
get
repositories
(
)
:
string
[
]
{
return
[
...
this
.
.
keys
(
)
]
;
}
constructor
(
)
{
this
.
onDidChangeRepositories
(
)
;
}
addRepository
(
:
string
,
:
string
)
:
void
{
this
.
.
set
(
,
)
;
this
.
onDidChangeRepositories
(
)
;
}
deleteRepository
(
:
string
)
:
boolean
{
const
=
this
.
.
delete
(
)
;
if
(
)
{
this
.
onDidChangeRepositories
(
)
;
}
return
;
}
getRepositoryPath
(
:
string
)
:
string
|
undefined
{
return
this
.
.
get
(
)
;
}
hasRepository
(
:
string
)
:
boolean
{
return
this
.
.
has
(
)
;
}
private
onDidChangeRepositories
(
)
:
void
{
.
executeCommand
(
'setContext'
,
'git.unsafeRepositoryCount'
,
this
.
.
)
;
}
}
export
class
Model
implements
IRepositoryResolver
,
,
,
,
,
{
private
=
new
EventEmitter< Repository>
(
)
;
readonly
:
<
>
=
this
.
.
;
private
=
new
EventEmitter< Repository>
(
)
;
readonly
:
<
>
=
this
.
.
;
private
=
new
EventEmitter< ModelChangeEvent>
(
)
;
readonly
:
<
>
=
this
.
.
;
private
=
new
EventEmitter< OriginalResourceChangeEvent>
(
)
;
readonly
:
<
>
=
this
.
.
;
private
:
[
]
=
[
]
;
get
repositories
(
)
:
[
]
{
return
this
.
.
map
(
=>
.
)
;
}
private
=
new
Set< string >
(
)
;
private
=
new
EventEmitter< State>
(
)
;
readonly
=
this
.
.
;
private
=
new
EventEmitter< PublishEvent>
(
)
;
readonly
=
this
.
.
;
firePublishEvent
(
:
,
?
:
string
)
{
this
.
.
fire
(
{
:
new
ApiRepository
(
)
,
:
}
)
;
}
private
:
=
'uninitialized'
;
get
state
(
)
:
{
return
this
.
;
}
setState
(
:
)
:
void
{
this
.
=
;
this
.
.
fire
(
)
;
.
executeCommand
(
'setContext'
,
'git.state'
,
)
;
}
@ memoize
get
isInitialized
(
)
:
Promise
<
void
>
{
if
(
this
.
===
'initialized'
)
{
return
Promise
.
resolve
(
)
;
}
return
eventToPromise
(
filterEvent
(
this
.
,
=>
===
'initialized'
)
as
<
unknown
>
)
as
Promise
<
void
>
;
}
private
=
new
Set< RemoteSourcePublisher>
(
)
;
private
=
new
EventEmitter< RemoteSourcePublisher>
(
)
;
readonly
=
this
.
.
;
private
=
new
EventEmitter< RemoteSourcePublisher>
(
)
;
readonly
=
this
.
.
;
private
=
new
Set< PostCommitCommandsProvider>
(
)
;
private
=
new
EventEmitter< void >
(
)
;
readonly
=
this
.
.
;
private
=
new
Map< string , Set< BranchProtectionProvider>>
(
)
;
private
=
new
EventEmitter< Uri>
(
)
;
readonly
=
this
.
.
;
private
=
new
Set< PushErrorHandler>
(
)
;
private
=
new
Set< SourceControlHistoryItemDetailsProvider>
(
)
;
private
:
;
get
unsafeRepositories
(
)
:
string
[
]
{
return
this
.
.
;
}
private
:
;
get
parentRepositories
(
)
:
string
[
]
{
return
this
.
.
;
}
private
:
;
get
closedRepositories
(
)
:
string
[
]
{
return
[
...
this
.
.
]
;
}
private
=
new
Map< string , string >
(
)
;
private
readonly
:
;
get
repositoryCache
(
)
:
{
return
this
.
;
}
private
readonly
=
new
Limiter< void >
(
5
)
;
private
:
[
]
=
[
]
;
constructor
(
readonly
:
,
private
readonly
:
,
private
:
,
readonly
:
,
private
:
,
private
readonly
:
)
{
this
.
=
new
ClosedRepositoriesManager
(
)
;
this
.
=
new
ParentRepositoriesManager
(
)
;
this
.
=
new
UnsafeRepositoriesManager
(
)
;
.
onDidChangeWorkspaceFolders
(
this
.
,
this
,
this
.
)
;
.
onDidChangeWorkspaceTrustedFolders
(
this
.
,
this
,
this
.
)
;
.
onDidChangeVisibleTextEditors
(
this
.
,
this
,
this
.
)
;
.
onDidChangeActiveTextEditor
(
this
.
,
this
,
this
.
)
;
.
onDidChangeConfiguration
(
this
.
,
this
,
this
.
)
;
const
=
.
createFileSystemWatcher
(
'**'
)
;
this
.
.
push
(
)
;
const
=
anyEvent
(
.
,
.
,
.
)
;
const
=
filterEvent
(
,
=>
/ \/ \. git/
.
test
(
.
)
)
;
const
=
filterEvent
(
,
=>
!
this
.
getRepository
(
)
)
;
onPossibleGitRepositoryChange
(
this
.
,
this
,
this
.
)
;
this
.
setState
(
'uninitialized'
)
;
this
.
doInitialScan
(
)
.
finally
(
(
)
=>
this
.
setState
(
'initialized'
)
)
;
this
.
=
new
RepositoryCache
(
,
)
;
}
private
async
doInitialScan
(
)
:
Promise
<
void
>
{
this
.
.
info
(
'[Model][doInitialScan] Initial repository scan started'
)
;
const
=
.
getConfiguration
(
'git'
)
;
const
=
.
get < boolean | 'subFolders' | 'openEditors' >
(
'autoRepositoryDetection'
)
;
const
=
.
get < 'always' | 'never' | 'prompt' >
(
'openRepositoryInParentFolders'
,
'prompt'
)
;
this
.
.
trace
(
` [Model][doInitialScan] Settings: autoRepositoryDetection= ${ autoRepositoryDetection} , openRepositoryInParentFolders= ${ parentRepositoryConfig} `
)
;
const
initialScanFn
=
(
)
=>
Promise
.
all
(
[
this
.
onDidChangeWorkspaceFolders
(
{
:
.
||
[
]
,
:
[
]
}
)
,
this
.
onDidChangeVisibleTextEditors
(
.
)
,
this
.
scanWorkspaceFolders
(
)
]
)
;
if
(
.
get < boolean >
(
'showProgress'
,
true
)
)
{
await
.
withProgress
(
{
:
.
}
,
)
;
}
else
{
await
initialScanFn
(
)
;
}
if
(
this
.
.
!==
0
&&
===
'prompt'
)
{
this
.
showParentRepositoryNotification
(
)
;
}
else
if
(
this
.
.
!==
0
)
{
this
.
showUnsafeRepositoryNotification
(
)
;
}
this
.
.
sendTelemetryEvent
(
'git.repositoryInitialScan'
,
{
:
String
(
)
}
,
{
:
this
.
.
}
)
;
this
.
.
info
(
` [Model][doInitialScan] Initial repository scan completed - repositories ( ${ this . repositories. length} ), closed repositories ( ${ this . closedRepositories. length} ), parent repositories ( ${ this . parentRepositories. length} ), unsafe repositories ( ${ this . unsafeRepositories. length} ) `
)
;
}
private
async
scanWorkspaceFolders
(
)
:
Promise
<
void
>
{
try
{
const
=
.
getConfiguration
(
'git'
)
;
const
=
.
get < boolean | 'subFolders' | 'openEditors' >
(
'autoRepositoryDetection'
)
;
if
(
!==
true
&&
!==
'subFolders'
)
{
return
;
}
await
Promise
.
all
(
(
.
||
[
]
)
.
map
(
async
=>
{
const
=
.
.
;
this
.
.
trace
(
` [Model][scanWorkspaceFolders] Workspace folder: ${ root} `
)
;
const
=
(
.
?
.
getConfiguration
(
'git'
,
.
)
:
)
.
get < number >
(
'repositoryScanMaxDepth'
,
1
)
;
const
=
(
.
?
.
getConfiguration
(
'git'
,
.
)
:
)
.
get < string [ ] >
(
'repositoryScanIgnoredFolders'
,
[
]
)
;
const
=
new
Set
(
await
this
.
traverseWorkspaceFolder
(
,
,
)
)
;
const
=
(
.
?
.
getConfiguration
(
'git'
,
.
)
:
)
.
get < string [ ] >
(
'scanRepositories'
)
||
[
]
;
this
.
.
trace
(
` [Model][scanWorkspaceFolders] Workspace scan settings: repositoryScanMaxDepth= ${ repositoryScanMaxDepth} ; repositoryScanIgnoredFolders=[ ${ repositoryScanIgnoredFolders. join ( ', ' ) } ]; scanRepositories=[ ${ scanPaths. join ( ', ' ) } ] `
)
;
for
(
const
of
)
{
if
(
===
'.git'
)
{
this
.
.
trace
(
'[Model][scanWorkspaceFolders] \'.git\' not supported in \'git.scanRepositories\' setting.'
)
;
continue
;
}
if
(
.
isAbsolute
(
)
)
{
const
=
.
t
(
'Absolute paths not supported in "git.scanRepositories" setting.'
)
;
this
.
.
warn
(
` [Model][scanWorkspaceFolders] ${ notSupportedMessage} `
)
;
console
.
warn
(
)
;
continue
;
}
.
add
(
.
join
(
,
)
)
;
}
this
.
.
trace
(
` [Model][scanWorkspaceFolders] Workspace scan sub folders: [ ${ [ ... subfolders] . join ( ', ' ) } ] `
)
;
await
Promise
.
all
(
[
...
]
.
map
(
=>
this
.
openRepository
(
)
)
)
;
}
)
)
;
}
catch
(
)
{
this
.
.
warn
(
` [Model][scanWorkspaceFolders] Error: ${ err} `
)
;
}
}
private
async
traverseWorkspaceFolder
(
:
string
,
:
number
,
:
string
[
]
)
:
Promise
<
string
[
]
>
{
const
:
string
[
]
=
[
]
;
const
=
[
{
:
,
:
0
}
]
;
while
(
.
>
0
)
{
const
=
.
shift
(
)
!
;
const
:
.
[
]
=
[
]
;
try
{
.
push
(
...
await
.
.
readdir
(
.
,
{
:
true
}
)
)
;
if
(
.
!==
0
)
{
.
push
(
.
)
;
}
}
catch
(
)
{
this
.
.
warn
(
` [Model][traverseWorkspaceFolder] Unable to read workspace folder ' ${ currentFolder. path} ': ${ err} `
)
;
continue
;
}
if
(
.
<
||
===
-
1
)
{
const
=
.
filter
(
=>
.
isDirectory
(
)
&&
.
!==
'.git'
&&
!
.
find
(
=>
pathEquals
(
.
,
)
)
)
.
map
(
=>
.
join
(
.
,
.
)
)
;
.
push
(
...
.
map
(
=>
{
return
{
:
,
:
.
+
1
}
;
}
)
)
;
}
}
return
;
}
private
onPossibleGitRepositoryChange
(
:
)
:
void
{
const
=
.
getConfiguration
(
'git'
)
;
const
=
.
get < boolean | 'subFolders' | 'openEditors' >
(
'autoRepositoryDetection'
)
;
if
(
===
false
)
{
return
;
}
this
.
eventuallyScanPossibleGitRepository
(
.
.
replace
(
/ \. git. * $ /
,
''
)
)
;
}
private
eventuallyScanPossibleGitRepository
(
:
string
)
{
this
.
.
add
(
)
;
this
.
eventuallyScanPossibleGitRepositories
(
)
;
}
@ debounce
(
500
)
private
eventuallyScanPossibleGitRepositories
(
)
:
void
{
for
(
const
of
this
.
)
{
this
.
openRepository
(
)
;
}
this
.
.
clear
(
)
;
}
private
async
onDidChangeWorkspaceFolders
(
{
,
}
:
)
:
Promise
<
void
>
{
try
{
const
=
.
filter
(
=>
!
this
.
getOpenRepository
(
.
)
)
;
const
=
.
.
map
(
=>
this
.
getRepository
(
.
.
)
)
.
filter
(
=>
!
!
)
as
[
]
;
const
=
new
Set< Repository>
(
)
;
const
=
.
map
(
=>
this
.
getOpenRepository
(
.
)
)
.
filter
(
=>
!
!
)
.
filter
(
=>
!
.
has
(
!
.
)
)
.
filter
(
=>
!
(
.
||
[
]
)
.
some
(
=>
isDescendant
(
.
.
,
!
.
.
)
)
)
as
[
]
;
.
forEach
(
=>
.
dispose
(
)
)
;
this
.
.
trace
(
` [Model][onDidChangeWorkspaceFolders] Workspace folders: [ ${ possibleRepositoryFolders. map ( p => p. uri. fsPath) . join ( ', ' ) } ] `
)
;
await
Promise
.
all
(
.
map
(
=>
this
.
openRepository
(
.
.
)
)
)
;
}
catch
(
)
{
this
.
.
warn
(
` [Model][onDidChangeWorkspaceFolders] Error: ${ err} `
)
;
}
}
private
async
onDidChangeWorkspaceTrustedFolders
(
)
:
Promise
<
void
>
{
try
{
const
:
[
]
=
[
]
;
for
(
const
of
this
.
)
{
const
=
.
.
.
??
.
.
.
;
const
=
await
.
isResourceTrusted
(
.
file
(
.
dirname
(
)
)
)
;
if
(
!
)
{
.
push
(
)
;
this
.
.
trace
(
` [Model][onDidChangeWorkspaceTrustedFolders] Repository is no longer trusted: ${ openRepository. repository. root} `
)
;
}
}
.
forEach
(
=>
.
dispose
(
)
)
;
}
catch
(
)
{
this
.
.
warn
(
` [Model][onDidChangeWorkspaceTrustedFolders] Error: ${ err} `
)
;
}
}
private
onDidChangeConfiguration
(
)
:
void
{
const
=
(
.
||
[
]
)
.
filter
(
=>
.
getConfiguration
(
'git'
,
.
)
.
get < boolean >
(
'enabled'
)
===
true
)
.
filter
(
=>
!
this
.
getOpenRepository
(
.
)
)
;
const
=
this
.
.
map
(
=>
(
{
,
:
.
file
(
.
.
)
}
)
)
.
filter
(
(
{
}
)
=>
.
getConfiguration
(
'git'
,
)
.
get < boolean >
(
'enabled'
)
!==
true
)
.
map
(
(
{
}
)
=>
)
;
this
.
.
trace
(
` [Model][onDidChangeConfiguration] Workspace folders: [ ${ possibleRepositoryFolders. map ( p => p. uri. fsPath) . join ( ', ' ) } ] `
)
;
.
forEach
(
=>
this
.
openRepository
(
.
.
)
)
;
.
forEach
(
=>
.
dispose
(
)
)
;
}
private
async
onDidChangeVisibleTextEditors
(
:
readonly
[
]
)
:
Promise
<
void
>
{
try
{
if
(
!
.
)
{
this
.
.
trace
(
'[Model][onDidChangeVisibleTextEditors] Workspace is not trusted.'
)
;
return
;
}
const
=
.
getConfiguration
(
'git'
)
;
const
=
.
get < boolean | 'subFolders' | 'openEditors' >
(
'autoRepositoryDetection'
)
;
if
(
!==
true
&&
!==
'openEditors'
)
{
return
;
}
await
Promise
.
all
(
.
map
(
async
=>
{
const
=
.
.
;
if
(
.
!==
'file'
)
{
return
;
}
const
=
this
.
getRepository
(
)
;
if
(
)
{
this
.
.
trace
(
` [Model][onDidChangeVisibleTextEditors] Repository for editor resource ${ uri. fsPath} already exists: ${ repository. root} `
)
;
return
;
}
this
.
.
trace
(
` [Model][onDidChangeVisibleTextEditors] Open repository for editor resource ${ uri. fsPath} `
)
;
await
this
.
openRepository
(
.
dirname
(
.
)
)
;
}
)
)
;
}
catch
(
)
{
this
.
.
warn
(
` [Model][onDidChangeVisibleTextEditors] Error: ${ err} `
)
;
}
}
private
onDidChangeActiveTextEditor
(
)
:
void
{
const
=
.
;
if
(
===
undefined
)
{
.
executeCommand
(
'setContext'
,
'git.activeResourceHasUnstagedChanges'
,
false
)
;
.
executeCommand
(
'setContext'
,
'git.activeResourceHasStagedChanges'
,
false
)
;
.
executeCommand
(
'setContext'
,
'git.activeResourceHasMergeConflicts'
,
false
)
;
return
;
}
const
=
this
.
getRepository
(
.
.
)
;
if
(
!
)
{
.
executeCommand
(
'setContext'
,
'git.activeResourceHasUnstagedChanges'
,
false
)
;
.
executeCommand
(
'setContext'
,
'git.activeResourceHasStagedChanges'
,
false
)
;
.
executeCommand
(
'setContext'
,
'git.activeResourceHasMergeConflicts'
,
false
)
;
return
;
}
const
=
.
.
.
find
(
=>
pathEquals
(
.
.
,
.
.
.
)
)
;
const
=
.
.
.
find
(
=>
pathEquals
(
.
.
,
.
.
.
)
)
;
const
=
.
.
.
find
(
=>
pathEquals
(
.
.
,
.
.
.
)
)
;
const
=
?
/ ^ ( <{7,} | ={7,} | >{7,} ) / m
.
test
(
.
.
getText
(
)
)
:
false
;
.
executeCommand
(
'setContext'
,
'git.activeResourceHasStagedChanges'
,
!==
undefined
)
;
.
executeCommand
(
'setContext'
,
'git.activeResourceHasUnstagedChanges'
,
!==
undefined
)
;
.
executeCommand
(
'setContext'
,
'git.activeResourceHasMergeConflicts'
,
)
;
}
@ sequentialize
async
openRepository
(
:
string
,
=
false
,
=
false
)
:
Promise
<
void
>
{
this
.
.
trace
(
` [Model][openRepository] Repository: ${ repoPath} `
)
;
const
=
await
this
.
getRepositoryExact
(
)
;
if
(
)
{
this
.
.
trace
(
` [Model][openRepository] Repository for path ${ repoPath} already exists: ${ existingRepository. root} `
)
;
return
;
}
const
=
.
getConfiguration
(
'git'
,
.
file
(
)
)
;
const
=
.
get < boolean >
(
'enabled'
)
===
true
;
if
(
!
)
{
this
.
.
trace
(
'[Model][openRepository] Git is not enabled'
)
;
return
;
}
try
{
const
{
,
}
=
await
this
.
getRepositoryRoot
(
)
;
this
.
.
trace
(
` [Model][openRepository] Repository root for path ${ repoPath} is: ${ repositoryRoot} `
)
;
const
=
await
this
.
getRepositoryExact
(
)
;
if
(
)
{
this
.
.
trace
(
` [Model][openRepository] Repository for path ${ repositoryRoot} already exists: ${ existingRepository. root} `
)
;
return
;
}
if
(
this
.
shouldRepositoryBeIgnored
(
)
)
{
this
.
.
trace
(
` [Model][openRepository] Repository for path ${ repositoryRoot} is ignored `
)
;
return
;
}
const
=
.
get < 'always' | 'never' | 'prompt' >
(
'openRepositoryInParentFolders'
,
'prompt'
)
;
if
(
!==
'always'
&&
this
.
.
get < boolean >
(
` parentRepository: ${ repositoryRoot} `
)
!==
true
)
{
const
=
await
this
.
isRepositoryOutsideWorkspace
(
)
;
if
(
!
&&
)
{
this
.
.
trace
(
` [Model][openRepository] Repository in parent folder: ${ repositoryRoot} `
)
;
if
(
!
this
.
.
hasRepository
(
)
)
{
if
(
this
.
===
'initialized'
&&
===
'prompt'
)
{
this
.
showParentRepositoryNotification
(
)
;
}
this
.
.
addRepository
(
)
;
}
return
;
}
}
if
(
&&
.
===
3
)
{
this
.
.
trace
(
` [Model][openRepository] Unsafe repository: ${ repositoryRoot} `
)
;
if
(
this
.
===
'initialized'
&&
!
this
.
.
hasRepository
(
)
)
{
this
.
showUnsafeRepositoryNotification
(
)
;
}
this
.
.
addRepository
(
,
[
2
]
)
;
return
;
}
if
(
!
&&
this
.
.
isRepositoryClosed
(
)
)
{
this
.
.
trace
(
` [Model][openRepository] Repository for path ${ repositoryRoot} is closed `
)
;
return
;
}
const
[
,
]
=
await
Promise
.
all
(
[
this
.
.
getRepositoryDotGit
(
)
,
this
.
getRepositoryRootRealPath
(
)
]
)
;
const
=
.
??
.
;
const
=
await
.
requestResourceTrust
(
{
:
.
t
(
'You are opening a repository from a location that is not trusted. Do you trust the authors of the files in the repository you are opening?'
)
,
:
.
file
(
.
dirname
(
)
)
,
}
)
;
if
(
!
)
{
this
.
.
trace
(
` [Model][openRepository] Repository folder is not trusted: ${ path. dirname ( dotGitPath) } `
)
;
return
;
}
const
=
this
.
.
open
(
,
,
,
this
.
)
;
const
=
new
Repository
(
,
this
,
this
,
this
,
this
,
this
,
this
,
this
.
,
this
.
,
this
.
,
this
.
)
;
this
.
open
(
)
;
this
.
.
deleteRepository
(
.
)
;
this
.
.
info
(
` [Model][openRepository] Opened repository (path): ${ repository. root} `
)
;
this
.
.
info
(
` [Model][openRepository] Opened repository (real path): ${ repository. rootRealPath ?? repository. root} `
)
;
this
.
.
info
(
` [Model][openRepository] Opened repository (kind): ${ gitRepository. kind} `
)
;
this
.
.
queue
(
(
)
=>
.
status
(
)
)
.
then
(
(
)
=>
{
this
.
.
update
(
.
,
[
]
,
.
)
;
}
)
;
}
catch
(
)
{
this
.
.
trace
(
` [Model][openRepository] Opening repository for path=' ${ repoPath} ' failed. Error: ${ err} `
)
;
}
}
async
openParentRepository
(
:
string
)
:
Promise
<
void
>
{
this
.
.
openRepository
(
)
;
await
this
.
openRepository
(
)
;
}
private
async
getRepositoryRoot
(
:
string
)
:
Promise
<
{
:
string
;
:
|
null
}
>
{
try
{
const
=
await
this
.
.
getRepositoryRoot
(
)
;
return
{
:
.
file
(
)
.
,
:
null
}
;
}
catch
(
)
{
const
=
/ ^ fatal: detected dubious ownership in repository at \' ( [ ^ '] + ) \' [ \s \S ] * git config --global --add safe\. directory '? ( [ ^ '\n ] + ) '? $ / m
.
exec
(
.
)
;
if
(
&&
.
===
3
)
{
return
{
:
.
normalize
(
[
1
]
)
,
}
;
}
throw
;
}
}
private
async
getRepositoryRootRealPath
(
:
string
)
:
Promise
<
string
|
undefined
>
{
try
{
const
=
await
.
.
realpath
(
)
;
return
!
pathEquals
(
,
)
?
:
undefined
;
}
catch
(
)
{
this
.
.
warn
(
` [Model][getRepositoryRootRealPath] Failed to get repository realpath for " ${ repositoryRoot} ": ${ err} `
)
;
return
undefined
;
}
}
private
shouldRepositoryBeIgnored
(
:
string
)
:
boolean
{
const
=
.
getConfiguration
(
'git'
)
;
const
=
.
get < string [ ] >
(
'ignoredRepositories'
)
||
[
]
;
for
(
const
of
)
{
if
(
.
isAbsolute
(
)
)
{
if
(
pathEquals
(
,
)
)
{
return
true
;
}
}
else
{
for
(
const
of
.
||
[
]
)
{
if
(
pathEquals
(
.
join
(
.
.
,
)
,
)
)
{
return
true
;
}
}
}
}
return
false
;
}
private
open
(
:
)
:
void
{
this
.
.
trace
(
` [Model][open] Repository: ${ repository. root} `
)
;
const
=
filterEvent
(
.
,
=>
===
.
)
;
const
=
onDidDisappearRepository
(
(
)
=>
dispose
(
)
)
;
const
=
.
.
onDidDisposeParent
(
(
)
=>
dispose
(
)
)
;
const
=
.
onDidChangeRepository
(
=>
this
.
.
fire
(
{
,
}
)
)
;
const
=
.
onDidChangeOriginalResource
(
=>
this
.
.
fire
(
{
,
}
)
)
;
const
=
.
getConfiguration
(
'git'
,
.
file
(
.
)
)
.
get < boolean >
(
'detectSubmodules'
)
as
boolean
;
const
=
.
getConfiguration
(
'git'
,
.
file
(
.
)
)
.
get < number >
(
'detectSubmodulesLimit'
)
as
number
;
const
=
.
getConfiguration
(
'git'
,
.
file
(
.
)
)
.
get < boolean >
(
'detectWorktrees'
)
as
boolean
;
const
=
.
getConfiguration
(
'git'
,
.
file
(
.
)
)
.
get < number >
(
'detectWorktreesLimit'
)
as
number
;
const
checkForSubmodules
=
(
)
=>
{
if
(
!
)
{
this
.
.
trace
(
'[Model][open] Automatic detection of git submodules is not enabled.'
)
;
return
;
}
if
(
.
.
>
)
{
.
showWarningMessage
(
.
t
(
'The "{0}" repository has {1} submodules which won\'t be opened automatically. You can still open each one individually by opening a file within.'
,
.
basename
(
.
)
,
.
.
)
)
;
.
dispose
(
)
;
}
.
.
slice
(
0
,
)
.
map
(
=>
.
join
(
.
,
.
)
)
.
forEach
(
=>
{
this
.
.
trace
(
` [Model][open] Opening submodule: ' ${ p} ' `
)
;
this
.
eventuallyScanPossibleGitRepository
(
)
;
}
)
;
}
;
const
checkForWorktrees
=
(
)
=>
{
if
(
!
)
{
this
.
.
trace
(
'[Model][open] Automatic detection of git worktrees is not enabled.'
)
;
return
;
}
if
(
.
===
'worktree'
)
{
this
.
.
trace
(
'[Model][open] Automatic detection of git worktrees is not skipped.'
)
;
return
;
}
if
(
.
.
>
)
{
.
showWarningMessage
(
.
t
(
'The "{0}" repository has {1} worktrees which won\'t be opened automatically. You can still open each one individually by opening a file within.'
,
.
basename
(
.
)
,
.
.
)
)
;
.
dispose
(
)
;
}
.
.
slice
(
0
,
)
.
forEach
(
=>
{
this
.
.
trace
(
` [Model][open] Opening worktree: ' ${ w. path} ' `
)
;
this
.
eventuallyScanPossibleGitRepository
(
.
)
;
}
)
;
}
;
const
updateMergeChanges
=
(
)
=>
{
const
:
[
]
=
[
]
;
for
(
const
{
}
of
this
.
.
values
(
)
)
{
for
(
const
of
.
.
)
{
.
push
(
.
)
;
}
}
.
executeCommand
(
'setContext'
,
'git.mergeChanges'
,
)
;
}
;
const
=
.
onDidRunGitStatus
(
(
)
=>
{
checkForSubmodules
(
)
;
checkForWorktrees
(
)
;
updateMergeChanges
(
)
;
this
.
onDidChangeActiveTextEditor
(
)
;
}
)
;
checkForSubmodules
(
)
;
checkForWorktrees
(
)
;
this
.
onDidChangeActiveTextEditor
(
)
;
const
updateOperationInProgressContext
=
(
)
=>
{
let
=
false
;
for
(
const
{
}
of
this
.
.
values
(
)
)
{
if
(
.
.
shouldDisableCommands
(
)
)
{
=
true
;
}
}
.
executeCommand
(
'setContext'
,
'operationInProgress'
,
)
;
}
;
const
=
anyEvent
(
.
as
<
unknown
>
,
.
as
<
unknown
>
)
;
const
=
operationEvent
(
(
)
=>
updateOperationInProgressContext
(
)
)
;
updateOperationInProgressContext
(
)
;
const
dispose
=
(
)
=>
{
.
dispose
(
)
;
.
dispose
(
)
;
.
dispose
(
)
;
.
dispose
(
)
;
.
dispose
(
)
;
.
dispose
(
)
;
.
dispose
(
)
;
this
.
=
this
.
.
filter
(
=>
!==
)
;
this
.
.
fire
(
)
;
}
;
const
=
{
,
}
;
this
.
.
push
(
)
;
updateMergeChanges
(
)
;
this
.
.
fire
(
)
;
}
close
(
:
)
:
void
{
const
=
this
.
getOpenRepository
(
)
;
if
(
!
)
{
return
;
}
this
.
.
info
(
` [Model][close] Repository: ${ repository. root} `
)
;
this
.
.
addRepository
(
.
.
)
;
this
.
.
update
(
.
,
[
]
,
.
)
;
.
dispose
(
)
;
}
async
pickRepository
(
?
:
(
'repository'
|
'submodule'
|
'worktree'
)
[
]
)
:
Promise
<
|
undefined
>
{
if
(
this
.
.
===
0
)
{
throw
new
Error
(
.
t
(
'There are no available repositories'
)
)
;
}
const
=
this
.
.
filter
(
=>
!
.
.
&&
(
!
||
.
includes
(
.
.
)
)
)
;
if
(
.
===
0
)
{
throw
new
Error
(
.
t
(
'There are no available repositories matching the filter'
)
)
;
}
else
if
(
.
===
1
)
{
return
[
0
]
.
;
}
const
=
.
;
const
=
.
map
(
(
,
)
=>
new
RepositoryPick
(
.
,
)
)
;
const
=
&&
this
.
getRepository
(
.
.
)
;
const
=
.
findIndex
(
=>
.
===
)
;
if
(
>
-
1
)
{
.
unshift
(
...
.
splice
(
,
1
)
)
;
}
const
=
.
t
(
'Choose a repository'
)
;
const
=
await
.
showQuickPick
(
,
{
}
)
;
return
&&
.
;
}
getRepository
(
:
|
|
|
string
)
:
|
undefined
{
const
=
this
.
getOpenRepository
(
)
;
return
&&
.
;
}
private
async
getRepositoryExact
(
:
string
)
:
Promise
<
|
undefined
>
{
const
=
this
.
.
find
(
=>
pathEquals
(
.
.
,
)
)
;
if
(
)
{
return
.
;
}
try
{
const
=
await
.
.
realpath
(
,
{
:
'utf8'
}
)
;
const
=
this
.
.
find
(
=>
pathEquals
(
.
.
??
.
.
,
)
)
;
return
?.
;
}
catch
(
)
{
this
.
.
warn
(
` [Model][getRepositoryExact] Failed to get repository realpath for: " ${ repoPath} ". Error: ${ err} `
)
;
return
undefined
;
}
}
private
getOpenRepository
(
:
|
|
|
|
string
)
:
|
undefined
{
if
(
!
)
{
return
undefined
;
}
if
(
instanceof
Repository
)
{
return
this
.
.
filter
(
=>
.
===
)
[
0
]
;
}
if
(
instanceof
ApiRepository
)
{
=
.
;
}
if
(
typeof
===
'string'
)
{
=
.
file
(
)
;
}
if
(
instanceof
Uri
)
{
let
:
string
;
if
(
.
===
'git'
)
{
=
fromGitUri
(
)
.
;
}
else
{
=
.
;
}
:
for
(
const
of
this
.
.
sort
(
(
,
)
=>
.
.
.
-
.
.
.
)
)
{
if
(
!
isDescendant
(
.
.
,
)
)
{
continue
;
}
for
(
const
of
.
.
)
{
const
=
.
join
(
.
.
,
.
)
;
if
(
isDescendant
(
,
)
)
{
continue
;
}
}
return
;
}
return
undefined
;
}
for
(
const
of
this
.
)
{
const
=
.
;
if
(
===
.
)
{
return
;
}
if
(
===
.
||
===
.
||
===
.
||
===
.
)
{
return
;
}
}
return
undefined
;
}
getRepositoryForSubmodule
(
:
)
:
|
undefined
{
for
(
const
of
this
.
)
{
for
(
const
of
.
)
{
const
=
.
join
(
.
,
.
)
;
if
(
===
.
)
{
return
;
}
}
}
return
undefined
;
}
registerRemoteSourcePublisher
(
:
)
:
{
this
.
.
add
(
)
;
this
.
.
fire
(
)
;
return
toDisposable
(
(
)
=>
{
this
.
.
delete
(
)
;
this
.
.
fire
(
)
;
}
)
;
}
getRemoteSourcePublishers
(
)
:
[
]
{
return
[
...
this
.
.
values
(
)
]
;
}
registerBranchProtectionProvider
(
:
,
:
)
:
{
const
:
[
]
=
[
]
;
this
.
.
set
(
.
toString
(
)
,
(
this
.
.
get
(
.
toString
(
)
)
??
new
Set
(
)
)
.
add
(
)
)
;
.
push
(
.
onDidChangeBranchProtection
(
=>
this
.
.
fire
(
)
)
)
;
this
.
.
fire
(
)
;
return
toDisposable
(
(
)
=>
{
const
=
this
.
.
get
(
.
toString
(
)
)
;
if
(
&&
.
has
(
)
)
{
.
delete
(
)
;
this
.
.
set
(
.
toString
(
)
,
)
;
this
.
.
fire
(
)
;
}
dispose
(
)
;
}
)
;
}
getBranchProtectionProviders
(
:
)
:
[
]
{
return
[
...
(
this
.
.
get
(
.
toString
(
)
)
??
new
Set
(
)
)
.
values
(
)
]
;
}
registerPostCommitCommandsProvider
(
:
)
:
{
this
.
.
add
(
)
;
this
.
.
fire
(
)
;
return
toDisposable
(
(
)
=>
{
this
.
.
delete
(
)
;
this
.
.
fire
(
)
;
}
)
;
}
getPostCommitCommandsProviders
(
)
:
[
]
{
return
[
...
this
.
.
values
(
)
]
;
}
registerCredentialsProvider
(
:
)
:
{
return
this
.
.
registerCredentialsProvider
(
)
;
}
registerPushErrorHandler
(
:
)
:
{
this
.
.
add
(
)
;
return
toDisposable
(
(
)
=>
this
.
.
delete
(
)
)
;
}
getPushErrorHandlers
(
)
:
[
]
{
return
[
...
this
.
]
;
}
registerSourceControlHistoryItemDetailsProvider
(
:
)
:
{
this
.
.
add
(
)
;
return
toDisposable
(
(
)
=>
this
.
.
delete
(
)
)
;
}
getSourceControlHistoryItemDetailsProviders
(
)
:
[
]
{
return
[
...
this
.
]
;
}
getUnsafeRepositoryPath
(
:
string
)
:
string
|
undefined
{
return
this
.
.
getRepositoryPath
(
)
;
}
deleteUnsafeRepository
(
:
string
)
:
boolean
{
return
this
.
.
deleteRepository
(
)
;
}
private
async
isRepositoryOutsideWorkspace
(
:
string
)
:
Promise
<
boolean
>
{
if
(
.
===
undefined
)
{
return
false
;
}
if
(
.
)
{
return
false
;
}
const
=
.
.
filter
(
=>
.
.
===
'file'
)
;
if
(
.
===
0
)
{
return
true
;
}
const
=
this
.
.
map
(
=>
.
.
map
(
=>
.
)
)
.
flat
(
)
;
if
(
.
some
(
=>
pathEquals
(
,
)
)
)
{
return
false
;
}
const
=
new
Set< string | undefined >
(
[
...
.
map
(
=>
.
.
)
,
...
await
Promise
.
all
(
.
map
(
=>
this
.
getWorkspaceFolderRealPath
(
)
)
)
]
)
;
return
!
Array
.
from
(
)
.
some
(
=>
&&
(
pathEquals
(
,
)
||
isDescendant
(
,
)
)
)
;
}
private
async
getWorkspaceFolderRealPath
(
:
)
:
Promise
<
string
|
undefined
>
{
let
=
this
.
.
get
(
.
.
)
;
if
(
!
)
{
try
{
=
await
.
.
realpath
(
.
.
,
{
:
'utf8'
}
)
;
this
.
.
set
(
.
.
,
)
;
}
catch
(
)
{
this
.
.
trace
(
` [Model][getWorkspaceFolderRealPath] Failed to resolve workspace folder " ${ workspaceFolder. uri. fsPath} ". Error: ${ err} `
)
;
}
}
return
;
}
private
async
showParentRepositoryNotification
(
)
:
Promise
<
void
>
{
const
=
this
.
.
===
1
?
.
t
(
'A git repository was found in the parent folders of the workspace or the open file(s). Would you like to open the repository?'
)
:
.
t
(
'Git repositories were found in the parent folders of the workspace or the open file(s). Would you like to open the repositories?'
)
;
const
=
.
t
(
'Yes'
)
;
const
=
.
t
(
'Always'
)
;
const
never
=
.
t
(
'Never'
)
;
const
=
await
.
showInformationMessage
(
,
,
,
never
)
;
if
(
===
)
{
.
executeCommand
(
'git.openRepositoriesInParentFolders'
)
;
}
else
if
(
===
||
===
never
)
{
const
=
.
getConfiguration
(
'git'
)
;
await
.
update
(
'openRepositoryInParentFolders'
,
===
?
'always'
:
'never'
,
true
)
;
if
(
===
)
{
for
(
const
of
this
.
)
{
await
this
.
openParentRepository
(
)
;
}
}
}
}
private
async
showUnsafeRepositoryNotification
(
)
:
Promise
<
void
>
{
if
(
this
.
.
===
0
)
{
return
;
}
const
=
this
.
.
===
1
?
.
t
(
'The git repository in the current folder is potentially unsafe as the folder is owned by someone other than the current user.'
)
:
.
t
(
'The git repositories in the current folder are potentially unsafe as the folders are owned by someone other than the current user.'
)
;
const
=
.
t
(
'Manage Unsafe Repositories'
)
;
const
=
.
t
(
'Learn More'
)
;
const
=
await
.
showErrorMessage
(
,
,
)
;
if
(
===
)
{
.
executeCommand
(
'git.manageUnsafeRepositories'
)
;
}
else
if
(
===
)
{
.
executeCommand
(
'vscode.open'
,
.
parse
(
'https://aka.ms/vscode-git-unsafe-repository'
)
)
;
}
}
dispose
(
)
:
void
{
const
=
[
...
this
.
]
;
.
forEach
(
=>
.
dispose
(
)
)
;
this
.
=
[
]
;
this
.
.
clear
(
)
;
this
.
=
dispose
(
this
.
)
;
}
}