ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / src / platform / git / test / node / gitService.spec.ts 550 строк · изменён 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
import assert from 'assert' ;
import { suite, test } from 'vitest' ;
import { AdoRepoId, getAdoRepoIdFromFetchUrl, getGithubRepoIdFromFetchUrl, GithubRepoId, normalizeFetchUrl, parseRemoteUrl, toGithubWebUrl } from '../../common/gitService' ;
function assertGitIdEquals ( a: GithubRepoId | undefined , b: { org: string ; repo: string ; host? : string } | undefined , message? : string
assert a org b org message
assert a repo b repo message
b host
assert a host b host message
assert
host rawHost path
assert
host rawHost path
assert
host rawHost path
assert
host rawHost path
assert
host rawHost path
assert
host rawHost path
assert
host rawHost path
assert
host rawHost path
assert
host rawHost path
assert
host rawHost path
result
assert result host
assert result rawHost
result
assert result host
assert result rawHost
url
result url
assert result
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
url
result url
assert result
url
result url
assert result
url
result url
assert result
url
result url
assert result
org repo
org repo
org repo
org repo
org repo
org repo
org repo
org repo
result
assert result host
result
assert result host
result
assert result host
result
assert result host
result
assert result host
result
assert result host
result
assert result host
result
assert result host
result
assert result host
result
assert result
assert result org
assert result repo
assert result host
result
assert result
assert result host
assert result org
assert result repo
result
assert result
assert result host
id
assert id host
id
assert id host
id
assert id
id GithubRepoId
assert id
assert id host
assert GithubRepoId
assert GithubRepoId
assert GithubRepoId
id
assert id type
id
assert id
id
assert id
id
assert id
id
assert id
result
assert result host
assert result rawHost
result
assert result host
assert result rawHost
result
assert result rawHost
assert result host
result
assert result rawHost
assert result host
result
assert result rawHost
result
assert result rawHost
url
result url
assert result url
url
result url
assert result
url
urlWithQuery
result urlWithQuery
assert result url
url
result url
assert result
url
result url
assert result
url
result url
assert result
url
result url
assert result
url
result url
assert result
url
result url
assert result
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
)
{
.
strictEqual
(
?.
,
?.
,
)
;
.
strictEqual
(
?.
,
?.
,
)
;
if
(
?.
!==
undefined
)
{
.
strictEqual
(
?.
,
.
,
)
;
}
}
suite
(
'parseRemoteUrl'
,
(
)
=>
{
test
(
'Should handle basic https'
,
(
)
=>
{
.
deepStrictEqual
(
parseRemoteUrl
(
'https://example.com/owner/repo.git'
)
,
{
:
'example.com'
,
:
'example.com'
,
:
'/owner/repo.git'
}
)
;
}
)
;
test
(
'Should find full subdomain with https'
,
(
)
=>
{
.
deepStrictEqual
(
parseRemoteUrl
(
'https://sub1.sub2.example.com/owner/repo.git'
)
,
{
:
'sub1.sub2.example.com'
,
:
'sub1.sub2.example.com'
,
:
'/owner/repo.git'
}
)
;
}
)
;
test
(
'Should handle basic Azure dev ops url'
,
(
)
=>
{
.
deepStrictEqual
(
parseRemoteUrl
(
'https://test@dev.azure.com/test/project/_git/vscode-stuff'
)
,
{
:
'dev.azure.com'
,
:
'dev.azure.com'
,
:
'/test/project/_git/vscode-stuff'
}
)
;
}
)
;
test
(
'Should handle basic visual studio url'
,
(
)
=>
{
.
deepStrictEqual
(
parseRemoteUrl
(
'https://test.visualstudio.com/project/one/_git/two'
)
,
{
:
'test.visualstudio.com'
,
:
'test.visualstudio.com'
,
:
'/project/one/_git/two'
}
)
;
}
)
;
test
(
'Should strip out ports'
,
(
)
=>
{
.
deepStrictEqual
(
parseRemoteUrl
(
'https://example.com:8080/owner/repo.git'
)
,
{
:
'example.com'
,
:
'example.com'
,
:
'/owner/repo.git'
}
)
;
}
)
;
test
(
'Should handle ssh syntax'
,
(
)
=>
{
.
deepStrictEqual
(
parseRemoteUrl
(
'ssh://git@github.com/owner/repo.git'
)
,
{
:
'github.com'
,
:
'github.com'
,
:
'/owner/repo.git'
}
)
;
}
)
;
test
(
'Should strip user ids'
,
(
)
=>
{
.
deepStrictEqual
(
parseRemoteUrl
(
'https://myname@github.com/owner/repo.git'
)
,
{
:
'github.com'
,
:
'github.com'
,
:
'/owner/repo.git'
}
,
'https, name only'
)
;
.
deepStrictEqual
(
parseRemoteUrl
(
'https://myname:ghp_1234556@github.com/owner/repo.git'
)
,
{
:
'github.com'
,
:
'github.com'
,
:
'/owner/repo.git'
}
,
'https, with name and PAT'
)
;
.
deepStrictEqual
(
parseRemoteUrl
(
'https://ghp_1234556@github.com/owner/repo.git'
)
,
{
:
'github.com'
,
:
'github.com'
,
:
'/owner/repo.git'
}
,
'https, PAT only'
)
;
.
deepStrictEqual
(
parseRemoteUrl
(
'ssh://name@github.com/owner/repo.git'
)
,
{
:
'github.com'
,
:
'github.com'
,
:
'/owner/repo.git'
}
,
'ssh, name only'
)
;
}
)
;
test
(
'Should preserve rawHost for SSH alias hostnames'
,
(
)
=>
{
const
=
parseRemoteUrl
(
'git@my-user-name-github.com:owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
.
strictEqual
(
?.
,
'my-user-name-github.com'
)
;
}
)
;
test
(
'Should handle GHE SSH shorthand with alias prefix'
,
(
)
=>
{
const
=
parseRemoteUrl
(
'msdemo-eu@msdemo-eu.ghe.com:sandbox/repo.git'
)
;
.
strictEqual
(
?.
,
'eu.ghe.com'
)
;
.
strictEqual
(
?.
,
'msdemo-eu.ghe.com'
)
;
}
)
;
}
)
;
suite
(
'getGithubRepoIdFromFetchUrl'
,
(
)
=>
{
test
(
'should return undefined for non-GitHub URLs'
,
(
)
=>
{
const
=
'https://example.com/owner/repo.git'
;
const
=
getGithubRepoIdFromFetchUrl
(
)
;
.
strictEqual
(
,
undefined
)
;
}
)
;
test
(
'should return the repo name for git shorthand URLs'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'git@github.com:owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'git@xyz.ghe.com:owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'ghe url'
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'org-123@github.com:owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
` non 'git' user name `
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'org-1234@xyz.github.com:owner-xyz/some-repo.git'
)
,
{
:
'owner-xyz'
,
:
'some-repo'
}
,
` non 'git' user name with subdomain alias `
)
;
}
)
;
test
(
'should return the repo name for HTTPS URLs'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://xyz.ghe.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'ghe url'
)
;
}
)
;
test
(
'should return the repos with trailing slash'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://github.com/owner/repo/'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://github.com/owner/repo.git/'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
}
)
;
test
(
'should return the repo name for URLs without .git extension'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://github.com/owner/repo'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://github.com/owner/repo/'
)
,
{
:
'owner'
,
:
'repo'
}
,
'With trailing slash'
)
;
}
)
;
test
(
'should return the repo name for ssh:// URLs'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'ssh://git@github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'ssh://git@github.com/owner/repo'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'ssh://git@ssh.github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'On ssh.github.com subdomain'
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'ssh://git@myco.ghe.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'ghe.com subdomain'
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'ssh://git@github.com:443/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'With port'
)
;
}
)
;
test
(
'should return undefined for invalid GitHub URLs'
,
(
)
=>
{
{
const
=
'https://github.com/owner'
;
const
=
getGithubRepoIdFromFetchUrl
(
)
;
.
deepStrictEqual
(
,
undefined
)
;
}
{
const
=
'https://github.com/'
;
const
=
getGithubRepoIdFromFetchUrl
(
)
;
.
deepStrictEqual
(
,
undefined
)
;
}
}
)
;
test
(
'should return undefined for invalid URLs'
,
(
)
=>
{
const
=
'invalid-url'
;
const
=
getGithubRepoIdFromFetchUrl
(
)
;
.
deepStrictEqual
(
,
undefined
)
;
}
)
;
test
(
'should return undefined for unsupported scheme'
,
(
)
=>
{
const
=
'gopher://github.com/owner/repo.git'
;
const
=
getGithubRepoIdFromFetchUrl
(
)
;
.
deepStrictEqual
(
,
undefined
)
;
}
)
;
test
(
'should support github url that uses www subdomain'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://www.github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
}
)
;
test
(
'should support github url using http'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'http://github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
)
;
}
)
;
test
(
'should support urls with custom user names and PAT in urls'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://myname@github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'https, name only'
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://myname:ghp_1234556@github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'https, with name and PAT'
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'https://ghp_1234556@github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'https, PAT only'
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'ssh://name@github.com/owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'ssh, name only'
)
;
}
)
;
test
(
'should support github urls that are likely ssh aliases'
,
(
)
=>
{
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'git@my-user-name-github.com:owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'Custom name before github.com'
)
;
assertGitIdEquals
(
getGithubRepoIdFromFetchUrl
(
'git@github.com-my-user-name:owner/repo.git'
)
,
{
:
'owner'
,
:
'repo'
}
,
'Custom name after github.com'
)
;
}
)
;
test
(
'should set host to github.com for github.com URLs'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'https://github.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should set host to ghe.com subdomain for GHE URLs'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'https://xyz.ghe.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'xyz.ghe.com'
)
;
}
)
;
test
(
'should set host to ghe.com subdomain for GHE SSH shorthand URLs'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'git@msdemo-eu.ghe.com:sandbox/repo.git'
)
;
.
strictEqual
(
?.
,
'msdemo-eu.ghe.com'
)
;
}
)
;
test
(
'should set host to github.com for SSH alias URLs'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'git@my-user-name-github.com:owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should set host to github.com for ssh:// github.com URLs'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'ssh://git@github.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should set host to ghe.com subdomain for ssh:// ghe URLs'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'ssh://git@myco.ghe.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'myco.ghe.com'
)
;
}
)
;
test
(
'should set host to github.com for http github.com URLs'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'http://github.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should set host to github.com for www.github.com URLs'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'https://www.github.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should set host to github.com for SSH alias with suffix'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'git@github.com-my-user-name:owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should resolve host and org/repo correctly for real-world GHE SSH shorthand'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'msdemo-eu@msdemo-eu.ghe.com:sandbox/repo.git'
)
;
.
ok
(
,
'Should parse successfully'
)
;
.
strictEqual
(
.
,
'sandbox'
)
;
.
strictEqual
(
.
,
'repo'
)
;
.
strictEqual
(
.
,
'msdemo-eu.ghe.com'
)
;
}
)
;
test
(
'should resolve host for GHE HTTPS with credentials'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'https://user@myco.ghe.com/org/repo.git'
)
;
.
ok
(
,
'Should parse successfully'
)
;
.
strictEqual
(
.
,
'myco.ghe.com'
)
;
.
strictEqual
(
.
,
'org'
)
;
.
strictEqual
(
.
,
'repo'
)
;
}
)
;
test
(
'should resolve host for GHE HTTPS without .git extension'
,
(
)
=>
{
const
=
getGithubRepoIdFromFetchUrl
(
'https://myco.ghe.com/org/repo'
)
;
.
ok
(
,
'Should parse successfully'
)
;
.
strictEqual
(
.
,
'myco.ghe.com'
)
;
}
)
;
}
)
;
suite
(
'GithubRepoId'
,
(
)
=>
{
test
(
'should default host to github.com'
,
(
)
=>
{
const
=
new
GithubRepoId
(
'owner'
,
'repo'
)
;
.
strictEqual
(
.
,
'github.com'
)
;
}
)
;
test
(
'should accept custom host'
,
(
)
=>
{
const
=
new
GithubRepoId
(
'owner'
,
'repo'
,
'myco.ghe.com'
)
;
.
strictEqual
(
.
,
'myco.ghe.com'
)
;
}
)
;
test
(
'toString should return org/repo without host'
,
(
)
=>
{
const
=
new
GithubRepoId
(
'Owner'
,
'Repo'
,
'myco.ghe.com'
)
;
.
strictEqual
(
.
toString
(
)
,
'owner/repo'
)
;
}
)
;
test
(
'parse should default host to github.com'
,
(
)
=>
{
const
=
.
parse
(
'owner/repo'
)
;
.
ok
(
)
;
.
strictEqual
(
.
,
'github.com'
)
;
}
)
;
test
(
'parse should return undefined for invalid nwo'
,
(
)
=>
{
.
strictEqual
(
.
parse
(
'invalid'
)
,
undefined
)
;
.
strictEqual
(
.
parse
(
'a/b/c'
)
,
undefined
)
;
.
strictEqual
(
.
parse
(
''
)
,
undefined
)
;
}
)
;
test
(
'type should be github'
,
(
)
=>
{
const
=
new
GithubRepoId
(
'owner'
,
'repo'
)
;
.
strictEqual
(
.
,
'github'
)
;
}
)
;
}
)
;
suite
(
'toGithubWebUrl'
,
(
)
=>
{
test
(
'should return github.com URL for default host'
,
(
)
=>
{
const
=
new
GithubRepoId
(
'owner'
,
'repo'
)
;
.
strictEqual
(
toGithubWebUrl
(
)
,
'https://github.com/owner/repo'
)
;
}
)
;
test
(
'should return GHE URL for custom host'
,
(
)
=>
{
const
=
new
GithubRepoId
(
'owner'
,
'repo'
,
'myco.ghe.com'
)
;
.
strictEqual
(
toGithubWebUrl
(
)
,
'https://myco.ghe.com/owner/repo'
)
;
}
)
;
test
(
'should preserve case in org and repo'
,
(
)
=>
{
const
=
new
GithubRepoId
(
'MyOrg'
,
'MyRepo'
,
'myco.ghe.com'
)
;
.
strictEqual
(
toGithubWebUrl
(
)
,
'https://myco.ghe.com/MyOrg/MyRepo'
)
;
}
)
;
test
(
'should handle deeply nested GHE subdomain'
,
(
)
=>
{
const
=
new
GithubRepoId
(
'org'
,
'repo'
,
'dept.company.ghe.com'
)
;
.
strictEqual
(
toGithubWebUrl
(
)
,
'https://dept.company.ghe.com/org/repo'
)
;
}
)
;
}
)
;
suite
(
'parseRemoteUrl rawHost'
,
(
)
=>
{
test
(
'should return matching host and rawHost for plain HTTPS URLs'
,
(
)
=>
{
const
=
parseRemoteUrl
(
'https://github.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should return matching host and rawHost for GHE HTTPS'
,
(
)
=>
{
const
=
parseRemoteUrl
(
'https://myco.ghe.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'myco.ghe.com'
)
;
.
strictEqual
(
?.
,
'myco.ghe.com'
)
;
}
)
;
test
(
'should return different host and rawHost for SSH alias prefix'
,
(
)
=>
{
const
=
parseRemoteUrl
(
'git@my-alias-github.com:owner/repo.git'
)
;
.
strictEqual
(
?.
,
'my-alias-github.com'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should return different host and rawHost for SSH alias suffix'
,
(
)
=>
{
const
=
parseRemoteUrl
(
'git@github.com-my-alias:owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com-my-alias'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should strip port from rawHost'
,
(
)
=>
{
const
=
parseRemoteUrl
(
'ssh://git@github.com:443/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'github.com'
)
;
}
)
;
test
(
'should strip user from rawHost'
,
(
)
=>
{
const
=
parseRemoteUrl
(
'https://user@myco.ghe.com/owner/repo.git'
)
;
.
strictEqual
(
?.
,
'myco.ghe.com'
)
;
}
)
;
}
)
;
suite
(
'Sanitize Remote Repo Urls'
,
(
)
=>
{
test
(
'Https url is unchanged'
,
(
)
=>
{
const
=
'https://github.com/owner/repo.git'
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
)
;
}
)
;
test
(
'Http url is converted to https'
,
(
)
=>
{
const
=
'http://github.com/owner/repo.git'
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
'https://github.com/owner/repo.git'
)
;
}
)
;
test
(
'Query parameters are removed'
,
(
)
=>
{
const
=
'https://github.com/owner/repo.git'
;
const
=
` ${ url} ?query=param `
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
)
;
}
)
;
test
(
'SSH is converted to HTTPS'
,
(
)
=>
{
const
=
'git@github.com:owner/repo.git'
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
'https://github.com/owner/repo.git'
)
;
}
)
;
test
(
'Credentials are removed from HTTPs url'
,
(
)
=>
{
const
=
'https://user:password@server.com/org/repo'
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
'https://server.com/org/repo'
)
;
}
)
;
test
(
'SSH ports are normalized and removed'
,
(
)
=>
{
const
=
'ssh://git@bitbucket.company.pl:7999/project/repo.git'
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
'https://bitbucket.company.pl/project/repo.git'
)
;
}
)
;
test
(
'Bitbucket https urls are properly normalized'
,
(
)
=>
{
const
=
'https://bitbucket.company.pl/scm/project/repo.git'
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
'https://bitbucket.company.pl/project/repo.git'
)
;
}
)
;
test
(
'Repos named scm by org foo are not improperly truncated'
,
(
)
=>
{
const
=
'https://github.com/foo/scm.git'
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
'https://github.com/foo/scm.git'
)
;
}
)
;
test
(
'Repos named scm by user scm are not improperly truncated'
,
(
)
=>
{
const
=
'https://github.com/scm/scm.git'
;
const
=
normalizeFetchUrl
(
)
;
.
strictEqual
(
,
'https://github.com/scm/scm.git'
)
;
}
)
;
}
)
;
suite
(
'getAdoRepoIdFromFetchUrl'
,
(
)
=>
{
test
(
'should return undefined for non-ADO URLs'
,
(
)
=>
{
.
strictEqual
(
getAdoRepoIdFromFetchUrl
(
'https://example.com/owner/repo.git'
)
,
undefined
)
;
.
strictEqual
(
getAdoRepoIdFromFetchUrl
(
'https://github.com/scm/scm.git'
)
,
undefined
)
;
}
)
;
test
(
'should parse https format'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'https://dev.azure.com/organization/project/_git/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse https format with _optimized'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'https://dev.azure.com/organization/project/_git/_optimized/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse https format with _full'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'https://dev.azure.com/organization/project/_git/_full/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse legacy https format'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'https://organization.visualstudio.com/project/_git/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse legacy https format with _optimized'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'https://organization.visualstudio.com/project/_git/_optimized/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse legacy https format with _full'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'https://organization.visualstudio.com/project/_git/_full/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse ssh format'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'git@ssh.dev.azure.com:v3/organization/project/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse ssh format with _optimized'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'git@ssh.dev.azure.com:v3/organization/project/_optimized/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse ssh format with _full'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'git@ssh.dev.azure.com:v3/organization/project/_full/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse legacy ssh format'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'git@organization.visualstudio.com:v3/organization/project/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse legacy ssh format with _optimized'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'git@organization.visualstudio.com:v3/organization/project/_optimized/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
test
(
'should parse legacy ssh format with _full'
,
(
)
=>
{
.
deepStrictEqual
(
getAdoRepoIdFromFetchUrl
(
'git@organization.visualstudio.com:v3/organization/project/_full/repository'
)
,
new
AdoRepoId
(
'organization'
,
'project'
,
'repository'
)
)
;
}
)
;
}
)
;