Skip to content

Commit 647a0b3

Browse files
andreeibzkat
authored andcommitted
fix(git): Fix gitRange for git+ssh for private git (#33)
1 parent 8425a96 commit 647a0b3

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

npa.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ function fromURL (res) {
231231
res.type = 'git'
232232
const match = urlparse.protocol === 'git+ssh:' && matchGitScp(res.rawSpec)
233233
if (match) {
234+
setGitCommittish(res, match.gitCommittish)
234235
res.fetchSpec = match.fetchSpec
235-
res.gitCommittish = match.gitCommittish
236236
} else {
237237
setGitCommittish(res, urlparse.hash != null ? urlparse.hash.slice(1) : '')
238238
urlparse.protocol = urlparse.protocol.replace(/^git[+]/, '')

test/basic.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ require('tap').test('basic', function (t) {
220220
raw: 'git+ssh://git@notgithub.com/user/foo#semver:^1.2.3'
221221
},
222222

223+
'git+ssh://git@notgithub.com:user/foo#semver:^1.2.3': {
224+
name: null,
225+
escapedName: null,
226+
type: 'git',
227+
hosted: null,
228+
saveSpec: 'git+ssh://git@notgithub.com:user/foo#semver:^1.2.3',
229+
fetchSpec: 'git@notgithub.com:user/foo',
230+
gitCommittish: null,
231+
gitRange: '^1.2.3',
232+
raw: 'git+ssh://git@notgithub.com:user/foo#semver:^1.2.3'
233+
},
234+
223235
'git+ssh://git@github.com/user/foo#semver:^1.2.3': {
224236
name: null,
225237
escapedName: null,
@@ -231,6 +243,17 @@ require('tap').test('basic', function (t) {
231243
raw: 'git+ssh://git@github.com/user/foo#semver:^1.2.3'
232244
},
233245

246+
'git+ssh://git@github.com:user/foo#semver:^1.2.3': {
247+
name: null,
248+
escapedName: null,
249+
type: 'git',
250+
saveSpec: 'git+ssh://git@github.com/user/foo.git#semver:^1.2.3',
251+
fetchSpec: 'ssh://git@github.com/user/foo.git',
252+
gitCommittish: null,
253+
gitRange: '^1.2.3',
254+
raw: 'git+ssh://git@github.com:user/foo#semver:^1.2.3'
255+
},
256+
234257
'user/foo#semver:^1.2.3': {
235258
name: null,
236259
escapedName: null,

0 commit comments

Comments
 (0)