fix: unshallow repository with credentials

This commit is contained in:
Anshuk Kumar 2018-05-01 19:17:15 +05:30 committed by Pierre Vanduynslager
parent c02b5cac6b
commit 45d7e6f25f
3 changed files with 8 additions and 6 deletions

View File

@ -57,7 +57,7 @@ async function run(options, plugins) {
await plugins.verifyConditions({options, logger}, {settleAll: true}); await plugins.verifyConditions({options, logger}, {settleAll: true});
// Unshallow the repo in order to get all the tags // Unshallow the repo in order to get all the tags
await unshallow(); await unshallow(options.repositoryUrl);
const lastRelease = await getLastRelease(options.tagFormat, logger); const lastRelease = await getLastRelease(options.tagFormat, logger);
const commits = await getCommits(lastRelease.gitHead, options.branch, logger); const commits = await getCommits(lastRelease.gitHead, options.branch, logger);

View File

@ -44,9 +44,11 @@ async function isRefInHistory(ref) {
/** /**
* Unshallow the git repository (retriving every commits and tags). * Unshallow the git repository (retriving every commits and tags).
*
* @param {String} repositoryUrl The remote repository URL with credentials.
*/ */
async function unshallow() { async function unshallow(repositoryUrl) {
await execa('git', ['fetch', '--unshallow', '--tags'], {reject: false}); await execa('git', ['fetch', '--unshallow', '--tags', repositoryUrl], {reject: false});
} }
/** /**

View File

@ -61,7 +61,7 @@ test.serial('Unshallow repository', async t => {
// Verify the shallow clone contains only one commit // Verify the shallow clone contains only one commit
t.is((await gitGetCommits()).length, 1); t.is((await gitGetCommits()).length, 1);
await unshallow(); await unshallow(repo);
// Verify the shallow clone contains all the commits // Verify the shallow clone contains all the commits
t.is((await gitGetCommits()).length, 2); 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 => { 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 // 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 // Add commits to the master branch
await gitCommits(['First']); 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 => { test.serial('Verify if the commit `sha` is in the direct history of the current branch', async t => {