fix: verify the local branch is up to date with the remote one

This commit is contained in:
pvdlg
2018-05-01 09:59:57 -04:00
committed by Pierre Vanduynslager
parent a11da0d5e3
commit d15905c0d5
5 changed files with 106 additions and 3 deletions
+10 -1
View File
@@ -13,7 +13,7 @@ const getLastRelease = require('./lib/get-last-release');
const {extractErrors} = require('./lib/utils');
const getGitAuthUrl = require('./lib/get-git-auth-url');
const logger = require('./lib/logger');
const {unshallow, verifyAuth, gitHead: getGitHead, tag, push} = require('./lib/git');
const {unshallow, verifyAuth, isBranchUpToDate, gitHead: getGitHead, tag, push} = require('./lib/git');
const getError = require('./lib/get-error');
marked.setOptions({renderer: new TerminalRenderer()});
@@ -47,6 +47,15 @@ async function run(options, plugins) {
await verify(options);
options.repositoryUrl = await getGitAuthUrl(options);
if (!await isBranchUpToDate(options.branch)) {
logger.log(
"The local branch %s is behind the remote one, therefore a new version won't be published.",
options.branch
);
return false;
}
if (!await verifyAuth(options.repositoryUrl, options.branch)) {
throw getError('EGITNOPERMISSION', {options});
}