Skip to content

Commit

Permalink
chore: use ghi.addHost for git tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Oct 18, 2022
1 parent bbe9edd commit c95b0a5
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions test/git.js
@@ -1,12 +1,11 @@
// set this up first, so we can use 127.0.0.1 as our "hosted git" service
const httpPort = 18000 + (+process.env.TAP_CHILD_ID || 0)
const hostedUrl = `http://localhost:${httpPort}`
const ghi = require('hosted-git-info/lib/git-host-info.js')
const HostedGit = require('hosted-git-info')
const gitPort = 12345 + (+process.env.TAP_CHILD_ID || 0)

ghi.byShortcut['localhost:'] = 'localhost'
ghi.byDomain.localhost = 'localhost'
ghi.localhost = {
HostedGit.addHost('localhost', {
domain: 'localhost',
protocols: ['git+https:', 'git+ssh:'],
tarballtemplate: () => `${hostedUrl}/repo-HEAD.tgz`,
sshurltemplate: (h) =>
Expand All @@ -17,11 +16,10 @@ ghi.localhost = {
const [, user, project] = url.pathname.split('/')
return { user, project, committish: url.hash.slice(1) }
},
}
})

ghi.byShortcut['localhosthttps:'] = 'localhosthttps'
ghi.byDomain['127.0.0.1'] = 'localhosthttps'
ghi.localhosthttps = {
HostedGit.addHost('localhosthttps', {
domain: '127.0.0.1',
protocols: ['git+https:', 'git+ssh:', 'git:'],
httpstemplate: (h) =>
`git://127.0.0.1:${gitPort}/${h.user}${h.committish ? `#${h.committish}` : ''}`,
Expand All @@ -30,11 +28,10 @@ ghi.localhosthttps = {
const [, user, project] = url.pathname.split('/')
return { user, project, committish: url.hash.slice(1) }
},
}
})

ghi.byShortcut['localhostssh:'] = 'localhostssh'
ghi.byDomain.localhostssh = 'localhostssh'
ghi.localhostssh = {
HostedGit.addHost('localhostssh', {
domain: 'localhostssh',
protocols: ['git+ssh:'],
tarballtemplate: () => `${hostedUrl}/repo-HEAD.tgz`,
sshurltemplate: (h) =>
Expand All @@ -47,7 +44,7 @@ ghi.localhostssh = {
const [, user, project] = url.pathname.split('/')
return { user, project, committish: url.hash.slice(1) }
},
}
})

const remote = `git://localhost:${gitPort}/repo`
const remoteHosted = `git://127.0.0.1:${gitPort}/repo`
Expand Down

0 comments on commit c95b0a5

Please sign in to comment.