Skip to content
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 support for specifying release branch #558

Merged
merged 3 commits into from Jul 24, 2020

Conversation

MunifTanjim
Copy link
Contributor

Fixes: #466

Based on: #476

@MunifTanjim MunifTanjim changed the title Add support for specifying relase branch Add support for specifying release branch Jul 20, 2020
@MunifTanjim MunifTanjim force-pushed the feature/branch branch 2 times, most recently from 8ebbe07 to 6320763 Compare July 20, 2020 16:02
readme.md Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

If this option is not specified, I think we should allow main too, just to make it easier in this transitional phase.

@MunifTanjim
Copy link
Contributor Author

MunifTanjim commented Jul 21, 2020

If this option is not specified, I think we should allow main too, just to make it easier in this transitional phase.

So should we hardcode both master & main here?

np/source/git-util.js

Lines 41 to 45 in b4bef72

exports.verifyCurrentBranchIsReleaseBranch = async (releaseBranch = 'master') => {
if (await exports.currentBranch() !== releaseBranch) {
throw new Error(`Not on \`${releaseBranch}\` branch. Use --any-branch to publish anyway, or set a different release branch using --branch.`);
}
};

Like this?

exports.verifyCurrentBranchIsReleaseBranch = async (releaseBranch) => {
	const allowedBranches = releaseBranch ? [releaseBranch] : ['master', 'main']
	const currentBranch = await exports.currentBranch()
	if (!allowedBranches.includes(currentBranch)) {
		throw new Error(`Not on ${allowedBranches.map(branch=> \`${branch}\`).join('/')} branch. Use --any-branch to publish anyway, or set a different release branch using --branch.`);
	}
};

@sindresorhus
Copy link
Owner

Correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only publish from a specific branch
2 participants