diff --git a/index.js b/index.js index fd971c66..e5395990 100644 --- a/index.js +++ b/index.js @@ -59,7 +59,7 @@ async function run(options, plugins) { try { await verifyAuth(options.repositoryUrl, options.branch); } catch (err) { - if (!(await isBranchUpToDate(options.repositoryUrl, options.branch))) { + 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 diff --git a/lib/git.js b/lib/git.js index 1e44ec98..1d841bc8 100644 --- a/lib/git.js +++ b/lib/git.js @@ -145,15 +145,14 @@ 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(repositoryUrl, branch) { +async function isBranchUpToDate(branch) { try { return await isRefInHistory( - (await execa.stdout('git', ['ls-remote', '--heads', repositoryUrl, branch])).match(/^(\w+)?/)[1] + (await execa.stdout('git', ['ls-remote', '--heads', 'origin', branch])).match(/^(\w+)?/)[1] ); } catch (err) { debug(err); diff --git a/test/git.test.js b/test/git.test.js index 63d2a3a1..c6fccfba 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -206,11 +206,11 @@ test.serial('Throws error if obtaining the tags fails', async t => { }); test.serial('Return "true" if repository is up to date', async t => { - const repositoryUrl = await gitRepo(true); + await gitRepo(true); await gitCommits(['First']); await gitPush(); - t.true(await isBranchUpToDate(repositoryUrl, 'master')); + t.true(await isBranchUpToDate('master')); }); test.serial('Return falsy if repository is not up to date', async t => { @@ -220,21 +220,21 @@ test.serial('Return falsy if repository is not up to date', async t => { await gitCommits(['Second']); await gitPush(); - t.true(await isBranchUpToDate(repositoryUrl, 'master')); + t.true(await isBranchUpToDate('master')); await gitShallowClone(repositoryUrl); await gitCommits(['Third']); await gitPush(); process.chdir(repoDir); - t.falsy(await isBranchUpToDate(repositoryUrl, 'master')); + t.falsy(await isBranchUpToDate('master')); }); test.serial('Return "true" if local repository is ahead', async t => { - const repositoryUrl = await gitRepo(true); + await gitRepo(true); await gitCommits(['First']); await gitPush(); await gitCommits(['Second']); - t.true(await isBranchUpToDate(repositoryUrl, 'master')); + t.true(await isBranchUpToDate('master')); });