From b750541d2b898eda75e8a36fbee698c9c1978599 Mon Sep 17 00:00:00 2001 From: eric sciple Date: Mon, 9 Dec 2019 17:01:19 -0500 Subject: . --- src/git-source-provider.ts | 4 ++-- src/github-api-helper.ts | 24 ++++++++++++++++++++++++ src/repository-api-helper.ts | 24 ------------------------ 3 files changed, 26 insertions(+), 26 deletions(-) create mode 100644 src/github-api-helper.ts delete mode 100644 src/repository-api-helper.ts (limited to 'src') diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index dc3e27e..f96cd5d 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -6,7 +6,7 @@ import * as gitCommandManager from './git-command-manager' import * as io from '@actions/io' import * as path from 'path' import * as refHelper from './ref-helper' -import * as repositoryApiHelper from './repository-api-helper' +import * as githubApiHelper from './github-api-helper' import {IGitCommandManager} from './git-command-manager' const authConfigKey = `http.https://github.com/.extraheader` @@ -79,7 +79,7 @@ export async function getSource(settings: ISourceSettings): Promise { } if (!git || `${1}` == '1') { - await repositoryApiHelper.download( + await githubApiHelper.downloadRepository( settings.accessToken, settings.repositoryOwner, settings.repositoryName, diff --git a/src/github-api-helper.ts b/src/github-api-helper.ts new file mode 100644 index 0000000..3da0154 --- /dev/null +++ b/src/github-api-helper.ts @@ -0,0 +1,24 @@ +import * as github from '@actions/github' +import {ReposGetArchiveLinkParams} from '@octokit/rest' + +const IS_WINDOWS = process.platform === 'win32' + +export async function downloadRepository( + accessToken: string, + owner: string, + repo: string, + ref: string, + repositoryPath: string +): Promise { + const octokit = new github.GitHub(accessToken) + const params: ReposGetArchiveLinkParams = { + archive_format: IS_WINDOWS ? 'zipball' : 'tarball', + owner: owner, + repo: repo, + ref: ref + } + const response = await octokit.repos.getArchiveLink(params) + console.log(`status=${response.status}`) + console.log(`headers=${JSON.stringify(response.headers)}`) + console.log(`data=${JSON.stringify(typeof response.data)}`) +} diff --git a/src/repository-api-helper.ts b/src/repository-api-helper.ts deleted file mode 100644 index 2e7d69b..0000000 --- a/src/repository-api-helper.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as github from '@actions/github' -import {ReposGetArchiveLinkParams} from '@octokit/rest' - -const IS_WINDOWS = process.platform === 'win32' - -export async function download( - accessToken: string, - owner: string, - repo: string, - ref: string, - repositoryPath: string -): Promise { - const octokit = new github.GitHub(accessToken) - const params: ReposGetArchiveLinkParams = { - archive_format: IS_WINDOWS ? 'zipball' : 'tarball', - owner: owner, - repo: repo, - ref: ref - } - const response = await octokit.repos.getArchiveLink(params) - console.log(`status=${response.status}`) - console.log(`headers=${JSON.stringify(response.headers)}`) - console.log(`data=${JSON.stringify(response.data)}`) -} -- cgit v1.2.3