From 59bb2dd7cdbba517519f03adbbfa26d683228209 Mon Sep 17 00:00:00 2001 From: eric sciple Date: Tue, 10 Dec 2019 02:58:11 -0500 Subject: [PATCH] . --- dist/index.js | 29 +++-------------------------- src/github-api-helper.ts | 36 +++--------------------------------- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/dist/index.js b/dist/index.js index 43edeb8..5d50de4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8376,12 +8376,12 @@ function downloadRepository(accessToken, owner, repo, ref, commit, repositoryPat // Download the archive let archiveData = yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { core.info('Downloading the archive using the REST API'); - yield yield downloadArchive(accessToken, owner, repo, ref, commit); + return yield downloadArchive(accessToken, owner, repo, ref, commit); })); // Write archive to disk core.info('Writing archive to disk'); yield fs.promises.writeFile(archivePath, archiveData); - archiveData = undefined; + archiveData = Buffer.from(''); // Free memory // // Get the archive URL using the REST API // await retryHelper.execute(async () => { // // Prepare the archive stream @@ -8407,28 +8407,12 @@ function downloadRepository(accessToken, owner, repo, ref, commit, repositoryPat // await fileStreamClosed // } // }) - // return Buffer.from(response.data) // response.data is ArrayBuffer - // // Download the archive - // core.info('Downloading the archive') // Do not print the URL since it contains a token to download the archive - // await downloadFile(archiveUrl, archivePath) - // // console.log(`status=${response.status}`) - // // console.log(`headers=${JSON.stringify(response.headers)}`) - // // console.log(`data=${response.data}`) - // // console.log(`data=${JSON.stringify(response.data)}`) - // // for (const key of Object.keys(response.data)) { - // // console.log(`data['${key}']=${response.data[key]}`) - // // } - // // Write archive to file - // const runnerTemp = process.env['RUNNER_TEMP'] as string - // assert.ok(runnerTemp, 'RUNNER_TEMP not defined') - // const archivePath = path.join(runnerTemp, 'checkout.tar.gz') - // await io.rmRF(archivePath) // await fs.promises.writeFile(archivePath, raw) // // await exec.exec(`ls -la "${archiveFile}"`, [], { // // cwd: repositoryPath // // } as ExecOptions) // Extract archive - const extractPath = path.join(runnerTemp, `checkout-archive${IS_WINDOWS ? '.zip' : '.tar.gz'}`); + const extractPath = path.join(runnerTemp, `checkout`); yield io.rmRF(extractPath); yield io.mkdirP(extractPath); if (IS_WINDOWS) { @@ -8476,13 +8460,6 @@ function downloadArchive(accessToken, owner, repo, ref, commit) { throw new Error(`Unexpected response from GitHub API. Status: '${response.status}'`); } return Buffer.from(response.data); // response.data is ArrayBuffer - // console.log('GETTING THE LOCATION') - // const archiveUrl = response.headers['Location'] // Do not print the archive URL because it has an embedded token - // assert.ok( - // archiveUrl, - // `Expected GitHub API response to contain 'Location' header` - // ) - // return archiveUrl }); } // async function getArchiveUrl( diff --git a/src/github-api-helper.ts b/src/github-api-helper.ts index 0be91f2..b3385a5 100644 --- a/src/github-api-helper.ts +++ b/src/github-api-helper.ts @@ -36,13 +36,13 @@ export async function downloadRepository( // Download the archive let archiveData = await retryHelper.execute(async () => { core.info('Downloading the archive using the REST API') - await await downloadArchive(accessToken, owner, repo, ref, commit) + return await downloadArchive(accessToken, owner, repo, ref, commit) }) // Write archive to disk core.info('Writing archive to disk') await fs.promises.writeFile(archivePath, archiveData) - archiveData = undefined + archiveData = Buffer.from('') // Free memory // // Get the archive URL using the REST API // await retryHelper.execute(async () => { @@ -72,35 +72,13 @@ export async function downloadRepository( // } // }) - // return Buffer.from(response.data) // response.data is ArrayBuffer - - // // Download the archive - // core.info('Downloading the archive') // Do not print the URL since it contains a token to download the archive - // await downloadFile(archiveUrl, archivePath) - - // // console.log(`status=${response.status}`) - // // console.log(`headers=${JSON.stringify(response.headers)}`) - // // console.log(`data=${response.data}`) - // // console.log(`data=${JSON.stringify(response.data)}`) - // // for (const key of Object.keys(response.data)) { - // // console.log(`data['${key}']=${response.data[key]}`) - // // } - - // // Write archive to file - // const runnerTemp = process.env['RUNNER_TEMP'] as string - // assert.ok(runnerTemp, 'RUNNER_TEMP not defined') - // const archivePath = path.join(runnerTemp, 'checkout.tar.gz') - // await io.rmRF(archivePath) // await fs.promises.writeFile(archivePath, raw) // // await exec.exec(`ls -la "${archiveFile}"`, [], { // // cwd: repositoryPath // // } as ExecOptions) // Extract archive - const extractPath = path.join( - runnerTemp, - `checkout-archive${IS_WINDOWS ? '.zip' : '.tar.gz'}` - ) + const extractPath = path.join(runnerTemp, `checkout`) await io.rmRF(extractPath) await io.mkdirP(extractPath) if (IS_WINDOWS) { @@ -160,14 +138,6 @@ async function downloadArchive( } return Buffer.from(response.data) // response.data is ArrayBuffer - - // console.log('GETTING THE LOCATION') - // const archiveUrl = response.headers['Location'] // Do not print the archive URL because it has an embedded token - // assert.ok( - // archiveUrl, - // `Expected GitHub API response to contain 'Location' header` - // ) - // return archiveUrl } // async function getArchiveUrl(