fix: use git ls-remote to verify if the remote branch is ahead

This commit is contained in:
Pierre Vanduynslager
2018-06-15 16:16:55 -04:00
parent 24a8052038
commit 2b6378f26f
6 changed files with 35 additions and 31 deletions
+9 -2
View File
@@ -141,12 +141,19 @@ async function verifyTagName(tagName) {
/**
* Verify the local branch is up to date with the remote one.
*
* @param {String} repositoryUrl The remote repository URL.
* @param {String} branch The repository branch for which to verify status.
*
* @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, falsy otherwise.
*/
async function isBranchUpToDate(branch) {
return isRefInHistory(await execa.stdout('git', ['rev-parse', `origin/${branch}`]));
async function isBranchUpToDate(repositoryUrl, branch) {
try {
return await isRefInHistory(
(await execa.stdout('git', ['ls-remote', '--heads', repositoryUrl, branch])).match(/^(\w+)?/)[1]
);
} catch (err) {
debug(err);
}
}
module.exports = {