Skip to content

Commit 5b2a731

Browse files
iarnazkat
authored andcommittedOct 18, 2017
Stop defaulting git-branch, return null when unset (#26)
BREAKING CHANGE: branch now defaults to `null` instead of `'master'`
1 parent ba0ae6a commit 5b2a731

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed
 

‎npa.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ function setGitCommittish (res, committish) {
140140
if (committish != null && committish.length >= 7 && committish.slice(0, 7) === 'semver:') {
141141
res.gitRange = decodeURIComponent(committish.slice(7))
142142
res.gitCommittish = null
143-
} else if (committish == null || committish === '') {
144-
res.gitCommittish = 'master'
145143
} else {
146-
res.gitCommittish = committish
144+
res.gitCommittish = committish === '' ? null : committish
147145
}
148146
return res
149147
}
@@ -213,7 +211,7 @@ function matchGitScp (spec) {
213211
const matched = spec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i)
214212
return matched && !matched[1].match(/:[0-9]+\/?.*$/i) && {
215213
fetchSpec: matched[1],
216-
gitCommittish: matched[2] || 'master'
214+
gitCommittish: matched[2] == null ? null : matched[2]
217215
}
218216
}
219217

‎test/basic.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ require('tap').test('basic', function (t) {
104104
type: 'git',
105105
saveSpec: 'git+ssh://git@notgithub.com/user/foo',
106106
fetchSpec: 'ssh://git@notgithub.com/user/foo',
107-
gitCommittish: 'master',
107+
gitCommittish: null,
108108
raw: 'git+ssh://git@notgithub.com/user/foo'
109109
},
110110

@@ -114,7 +114,7 @@ require('tap').test('basic', function (t) {
114114
type: 'git',
115115
saveSpec: 'git+ssh://git@notgithub.com:user/foo',
116116
fetchSpec: 'git@notgithub.com:user/foo',
117-
gitCommittish: 'master',
117+
gitCommittish: null,
118118
raw: 'git+ssh://git@notgithub.com:user/foo'
119119
},
120120

@@ -124,7 +124,7 @@ require('tap').test('basic', function (t) {
124124
type: 'git',
125125
saveSpec: 'git+ssh://mydomain.com:foo',
126126
fetchSpec: 'mydomain.com:foo',
127-
gitCommittish: 'master',
127+
gitCommittish: null,
128128
raw: 'git+ssh://mydomain.com:foo'
129129
},
130130

@@ -184,7 +184,7 @@ require('tap').test('basic', function (t) {
184184
type: 'git',
185185
saveSpec: 'git+ssh://mydomain.com:1234/hey',
186186
fetchSpec: 'ssh://mydomain.com:1234/hey',
187-
gitCommittish: 'master',
187+
gitCommittish: null,
188188
raw: 'git+ssh://mydomain.com:1234/hey'
189189
},
190190

0 commit comments

Comments
 (0)
Please sign in to comment.