Skip to content

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
@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