Skip to content

Commit c285551

Browse files
committedJul 1, 2021
@npmcli/git@2.1.0, update tests to work with latest hosted-git-info
1 parent 745265a commit c285551

File tree

3 files changed

+754
-1112
lines changed

3 files changed

+754
-1112
lines changed
 

‎package-lock.json

+723-1,073
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"git"
3434
],
3535
"dependencies": {
36-
"@npmcli/git": "^2.0.1",
36+
"@npmcli/git": "^2.1.0",
3737
"@npmcli/installed-package-contents": "^1.0.6",
3838
"@npmcli/promise-spawn": "^1.2.0",
3939
"@npmcli/run-script": "^1.8.2",

‎test/git.js

+30-38
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,42 @@ const hostedUrl = `http://localhost:${httpPort}`
44
const ghi = require('hosted-git-info/git-host-info.js')
55
const gitPort = 12345 + (+process.env.TAP_CHILD_ID || 0)
66

7+
ghi.byShortcut['localhost:'] = 'localhost'
8+
ghi.byDomain.localhost = 'localhost'
79
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: /^\/(repo|submodule-repo)/,
17-
hashformat: h => h,
18-
protocols_re: /^(git):$/
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+
}
1918
}
2019

20+
ghi.byShortcut['localhosthttps:'] = 'localhosthttps'
21+
ghi.byDomain['127.0.0.1'] = 'localhosthttps'
2122
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: /^\/(repo|submodule-repo|no-repo-here)/,
34-
hashformat: h => h,
35-
protocols_re: /^(git|git\+https):|$/
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+
}
3630
}
3731

32+
ghi.byShortcut['localhostssh:'] = 'localhostssh'
33+
ghi.byDomain.localhostssh = 'localhostssh'
3834
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: /^\/(repo|submodule-repo)/,
49-
hashformat: h => h,
50-
protocols_re: /^(git):$/
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+
}
5143
}
5244

5345
const remote = `git://localhost:${gitPort}/repo`
@@ -481,7 +473,7 @@ t.test('include auth with hosted https when provided', async t => {
481473
'using the correct dummy hosted service')
482474
const path = t.testdir({})
483475
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` ],
485477
})
486478
})
487479
})

0 commit comments

Comments
 (0)
Please sign in to comment.