-
-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --branch
flag for specifying default branch
#476
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -38,8 +38,8 @@ exports.currentBranch = async () => { | |||||
return stdout; | ||||||
}; | ||||||
|
||||||
exports.verifyCurrentBranchIsMaster = async () => { | ||||||
if (await exports.currentBranch() !== 'master') { | ||||||
exports.verifyCurrentBranchIsDefault = async (defaultBranch = 'master') => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to define a default value here, as it's set by |
||||||
if (await exports.currentBranch() !== defaultBranch) { | ||||||
throw new Error('Not on `master` branch. Use --any-branch to publish anyway.'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
}; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,31 @@ | ||||||
import test from 'ava'; | ||||||
import sinon from 'sinon'; | ||||||
import gitUtil from '../source/git-util'; | ||||||
|
||||||
const sandbox = sinon.createSandbox(); | ||||||
const currentBranchStub = sinon.stub(gitUtil, 'currentBranch'); | ||||||
|
||||||
test.afterEach(() => { | ||||||
sandbox.restore(); | ||||||
}); | ||||||
|
||||||
test('verifyCurrentBranchIsDefault doesn\'t throw if current branch is master', async t => { | ||||||
currentBranchStub.returns('master'); | ||||||
await t.notThrowsAsync(gitUtil.verifyCurrentBranchIsDefault); | ||||||
}); | ||||||
|
||||||
test('verifyCurrentBranchIsDefault throws if current branch is not master', async t => { | ||||||
currentBranchStub.returns('not master'); | ||||||
await t.throwsAsync(gitUtil.verifyCurrentBranchIsDefault); | ||||||
}); | ||||||
|
||||||
test('verifyCurrentBranchIsDefault doesn\'t throw if current branch the specified default branch', async t => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const currentBranchName = 'bestBranch'; | ||||||
currentBranchStub.returns(currentBranchName); | ||||||
await t.notThrowsAsync(gitUtil.verifyCurrentBranchIsDefault(currentBranchName)); | ||||||
}); | ||||||
|
||||||
test('verifyCurrentBranchIsDefault throws if current branch is not default branch', async t => { | ||||||
currentBranchStub.returns('unicorn-wrangler'); | ||||||
await t.throwsAsync(gitUtil.verifyCurrentBranchIsDefault('unicorn')); | ||||||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.