@@ -4,50 +4,42 @@ const hostedUrl = `http://localhost:${httpPort}`
4
4
const ghi = require ( 'hosted-git-info/git-host-info.js' )
5
5
const gitPort = 12345 + ( + process . env . TAP_CHILD_ID || 0 )
6
6
7
+ ghi . byShortcut [ 'localhost:' ] = 'localhost'
8
+ ghi . byDomain . localhost = 'localhost'
7
9
ghi . localhost = {
8
- protocols : [ 'git+https' , 'git+ssh' ] ,
9
- domain : `127.0.0.1:${ gitPort } ` ,
10
- httpstemplate : 'git://{domain}/{user}{#committish}' ,
11
- treepath : 'not-implemented' ,
12
- tarballtemplate : `${ hostedUrl } /repo-HEAD.tgz` ,
13
- // shortcut MUST have a user and project, at least
14
- shortcuttemplate : '{type}:{user}/x{#committish}' ,
15
- pathtemplate : '/{user}{#committish}' ,
16
- pathmatch : / ^ \/ ( r e p o | s u b m o d u l e - r e p o ) / ,
17
- hashformat : h => h ,
18
- protocols_re : / ^ ( g i t ) : $ /
10
+ protocols : [ 'git+https:' , 'git+ssh:' ] ,
11
+ tarballtemplate : ( ) => `${ hostedUrl } /repo-HEAD.tgz` ,
12
+ sshurltemplate : ( h ) => `git://127.0.0.1:${ gitPort } /${ h . user } ${ h . committish ? `#${ h . committish } ` : '' } ` ,
13
+ shortcuttemplate : ( h ) => `localhost:${ h . user } /${ h . project } ${ h . committish ? `#${ h . committish } ` : '' } ` ,
14
+ extract : ( url ) => {
15
+ const [ , user , project ] = url . pathname . split ( '/' )
16
+ return { user, project, committish : url . hash . slice ( 1 ) }
17
+ }
19
18
}
20
19
20
+ ghi . byShortcut [ 'localhosthttps:' ] = 'localhosthttps'
21
+ ghi . byDomain [ '127.0.0.1' ] = 'localhosthttps'
21
22
ghi . localhosthttps = {
22
- protocols : [ 'git+https' , 'git+ssh' ] ,
23
- domain : `127.0.0.1` ,
24
-
25
- httpstemplate : `git://127.0.0.1:${ gitPort } /{user}{#committish}` ,
26
- sshtemplate : 'git://nope this should never be used' ,
27
- sshurltemplate : 'git://nope this should never be used either' ,
28
-
29
- treepath : 'not-implemented' ,
30
- // shortcut MUST have a user and project, at least
31
- shortcuttemplate : '{type}:{user}/x{#committish}' ,
32
- pathtemplate : '/{user}{#committish}' ,
33
- pathmatch : / ^ \/ ( r e p o | s u b m o d u l e - r e p o | n o - r e p o - h e r e ) / ,
34
- hashformat : h => h ,
35
- protocols_re : / ^ ( g i t | g i t \+ h t t p s ) : | $ /
23
+ protocols : [ 'git+https:' , 'git+ssh:' , 'git:' ] ,
24
+ httpstemplate : ( h ) => `git://127.0.0.1:${ gitPort } /${ h . user } ${ h . committish ? `#${ h . committish } ` : '' } ` ,
25
+ shortcuttemplate : ( h ) => `localhosthttps:${ h . user } /x${ h . committish ? `#${ h . committish } ` : '' } ` ,
26
+ extract : ( url ) => {
27
+ const [ , user , project ] = url . pathname . split ( '/' )
28
+ return { user, project, committish : url . hash . slice ( 1 ) }
29
+ }
36
30
}
37
31
32
+ ghi . byShortcut [ 'localhostssh:' ] = 'localhostssh'
33
+ ghi . byDomain . localhostssh = 'localhostssh'
38
34
ghi . localhostssh = {
39
- protocols : [ 'git+ssh' ] ,
40
- domain : `localhostssh:${ gitPort } ` ,
41
- sshtemplate : `git://127.0.0.1:${ gitPort } /{user}{#committish}` ,
42
- sshurltemplate : `git://127.0.0.1:${ gitPort } /{user}{#committish}` ,
43
- treepath : 'not-implemented' ,
44
- tarballtemplate : `${ hostedUrl } /repo-HEAD.tgz` ,
45
- // shortcut MUST have a user and project, at least
46
- shortcuttemplate : '{type}:{user}/x{#committish}' ,
47
- pathtemplate : '/{user}{#committish}' ,
48
- pathmatch : / ^ \/ ( r e p o | s u b m o d u l e - r e p o ) / ,
49
- hashformat : h => h ,
50
- protocols_re : / ^ ( g i t ) : $ /
35
+ protocols : [ 'git+ssh:' ] ,
36
+ tarballtemplate : ( ) => `${ hostedUrl } /repo-HEAD.tgz` ,
37
+ sshurltemplate : ( h ) => `git://127.0.0.1:${ gitPort } /${ h . user } ${ h . committish ? `#${ h . committish } ` : '' } ` ,
38
+ shortcuttemplate : ( h ) => `localhostssh:${ h . user } /${ h . project } ${ h . committish ? `#${ h . committish } ` : '' } ` ,
39
+ extract : ( url ) => {
40
+ const [ , user , project ] = url . pathname . split ( '/' )
41
+ return { user, project, committish : url . hash . slice ( 1 ) }
42
+ }
51
43
}
52
44
53
45
const remote = `git://localhost:${ gitPort } /repo`
@@ -481,7 +473,7 @@ t.test('include auth with hosted https when provided', async t => {
481
473
'using the correct dummy hosted service' )
482
474
const path = t . testdir ( { } )
483
475
await t . rejects ( failer . extract ( path ) , {
484
- args : [ 'ls-remote' , `git://127.0.0.1:${ gitPort } /no-repo-here` ] ,
476
+ args : [ '--no-replace-objects' , ' ls-remote', `git://127.0.0.1:${ gitPort } /no-repo-here` ] ,
485
477
} )
486
478
} )
487
479
} )
0 commit comments