From 45d7e6f25f35b951b14e21d088203c62538c2dfb Mon Sep 17 00:00:00 2001 From: Anshuk Kumar Date: Tue, 1 May 2018 19:17:15 +0530 Subject: [PATCH] fix: unshallow repository with credentials --- index.js | 2 +- lib/git.js | 6 ++++-- test/git.test.js | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index dee083da..983a3c7a 100644 --- a/index.js +++ b/index.js @@ -57,7 +57,7 @@ async function run(options, plugins) { await plugins.verifyConditions({options, logger}, {settleAll: true}); // Unshallow the repo in order to get all the tags - await unshallow(); + await unshallow(options.repositoryUrl); const lastRelease = await getLastRelease(options.tagFormat, logger); const commits = await getCommits(lastRelease.gitHead, options.branch, logger); diff --git a/lib/git.js b/lib/git.js index 29d10f92..160d0aa8 100644 --- a/lib/git.js +++ b/lib/git.js @@ -44,9 +44,11 @@ async function isRefInHistory(ref) { /** * Unshallow the git repository (retriving every commits and tags). + * + * @param {String} repositoryUrl The remote repository URL with credentials. */ -async function unshallow() { - await execa('git', ['fetch', '--unshallow', '--tags'], {reject: false}); +async function unshallow(repositoryUrl) { + await execa('git', ['fetch', '--unshallow', '--tags', repositoryUrl], {reject: false}); } /** diff --git a/test/git.test.js b/test/git.test.js index f6ce186f..221a7863 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -61,7 +61,7 @@ test.serial('Unshallow repository', async t => { // Verify the shallow clone contains only one commit t.is((await gitGetCommits()).length, 1); - await unshallow(); + await unshallow(repo); // Verify the shallow clone contains all the commits t.is((await gitGetCommits()).length, 2); @@ -69,10 +69,10 @@ test.serial('Unshallow repository', async t => { test.serial('Do not throw error when unshallow a complete repository', async t => { // Create a git repository, set the current working directory at the root of the repo - await gitRepo(); + const repo = await gitRepo(); // Add commits to the master branch await gitCommits(['First']); - await t.notThrows(unshallow()); + await t.notThrows(unshallow(repo)); }); test.serial('Verify if the commit `sha` is in the direct history of the current branch', async t => {