@@ -183,10 +183,11 @@ Result.prototype.toJSON = function () {
183
183
return result
184
184
}
185
185
186
- function setGitCommittish ( res , committish ) {
186
+ // sets res.gitCommittish, res.gitRange, and res.gitSubdir
187
+ function setGitAttrs ( res , committish ) {
187
188
if ( ! committish ) {
188
189
res . gitCommittish = null
189
- return res
190
+ return
190
191
}
191
192
192
193
// for each :: separated item:
@@ -224,8 +225,6 @@ function setGitCommittish (res, committish) {
224
225
}
225
226
log . warn ( 'npm-package-arg' , `ignoring unknown key "${ name } "` )
226
227
}
227
-
228
- return res
229
228
}
230
229
231
230
function fromFile ( res , where ) {
@@ -303,7 +302,8 @@ function fromHostedGit (res, hosted) {
303
302
res . hosted = hosted
304
303
res . saveSpec = hosted . toString ( { noGitPlus : false , noCommittish : false } )
305
304
res . fetchSpec = hosted . getDefaultRepresentation ( ) === 'shortcut' ? null : hosted . toString ( )
306
- return setGitCommittish ( res , hosted . committish )
305
+ setGitAttrs ( res , hosted . committish )
306
+ return res
307
307
}
308
308
309
309
function unsupportedURLType ( protocol , spec ) {
@@ -326,7 +326,7 @@ function fromURL (res) {
326
326
const matched = rawSpec . match ( / ^ g i t \+ s s h : \/ \/ ( [ ^ : # ] + : [ ^ # ] + (?: \. g i t ) ? ) (?: # ( .* ) ) ? $ / i)
327
327
if ( matched && ! matched [ 1 ] . match ( / : [ 0 - 9 ] + \/ ? .* $ / i) ) {
328
328
res . type = 'git'
329
- setGitCommittish ( res , matched [ 2 ] )
329
+ setGitAttrs ( res , matched [ 2 ] )
330
330
res . fetchSpec = matched [ 1 ]
331
331
return res
332
332
}
@@ -345,7 +345,7 @@ function fromURL (res) {
345
345
case 'git+file:' :
346
346
case 'git+ssh:' :
347
347
res . type = 'git'
348
- setGitCommittish ( res , parsedUrl . hash . slice ( 1 ) )
348
+ setGitAttrs ( res , parsedUrl . hash . slice ( 1 ) )
349
349
if ( parsedUrl . protocol === 'git+file:' && / ^ g i t \+ f i l e : \/ \/ [ a - z ] : / i. test ( rawSpec ) ) {
350
350
// URL can't handle drive letters on windows file paths, the host can't contain a :
351
351
res . fetchSpec = `git+file://${ parsedUrl . host . toLowerCase ( ) } :${ parsedUrl . pathname } `
0 commit comments