Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreric sciple <ericsciple@users.noreply.github.com>2019-12-09 19:15:39 -0500
committereric sciple <ericsciple@users.noreply.github.com>2019-12-09 19:15:39 -0500
commit850c5af644079513a188c19cd4e77a9cba3ce0a2 (patch)
tree3f88eb56a5331aebfd7ae9c83cd9fcdf8fc4e999 /src
parent60d4cd61a0add35bf3fff62db8d96cc40adbdcf3 (diff)
.
Diffstat (limited to 'src')
-rw-r--r--src/git-command-manager.ts12
-rw-r--r--src/git-source-provider.ts6
-rw-r--r--src/github-api-helper.ts18
3 files changed, 29 insertions, 7 deletions
diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts
index 6e4f22f..70dce8f 100644
--- a/src/git-command-manager.ts
+++ b/src/git-command-manager.ts
@@ -5,6 +5,10 @@ import * as io from '@actions/io'
import * as path from 'path'
import {GitVersion} from './git-version'
+// Auth header not supported before 2.9
+// Wire protocol v2 not supported before 2.18
+export const MinimumGitVersion = new GitVersion('2.18')
+
export interface IGitCommandManager {
branchDelete(remote: boolean, branch: string): Promise<void>
branchExists(remote: boolean, pattern: string): Promise<boolean>
@@ -338,13 +342,9 @@ class GitCommandManager {
}
// Minimum git version
- // Note:
- // - Auth header not supported before 2.9
- // - Wire protocol v2 not supported before 2.18
- const minimumGitVersion = new GitVersion('2.18')
- if (!gitVersion.checkMinimum(minimumGitVersion)) {
+ if (!gitVersion.checkMinimum(MinimumGitVersion)) {
throw new Error(
- `Minimum required git version is ${minimumGitVersion}. Your git ('${this.gitPath}') is ${gitVersion}`
+ `Minimum required git version is ${MinimumGitVersion}. Your git ('${this.gitPath}') is ${gitVersion}`
)
}
diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts
index f96cd5d..487a8ee 100644
--- a/src/git-source-provider.ts
+++ b/src/git-source-provider.ts
@@ -79,6 +79,12 @@ export async function getSource(settings: ISourceSettings): Promise<void> {
}
if (!git || `${1}` == '1') {
+ core.info(
+ `Git version ${gitCommandManager.MinimumGitVersion} was not found in the PATH.`
+ )
+ core.info(
+ `Instead downloading the repository files using the GitHub REST API.`
+ )
await githubApiHelper.downloadRepository(
settings.accessToken,
settings.repositoryOwner,
diff --git a/src/github-api-helper.ts b/src/github-api-helper.ts
index 44fdd73..aa4ded2 100644
--- a/src/github-api-helper.ts
+++ b/src/github-api-helper.ts
@@ -1,5 +1,13 @@
+import * as assert from 'assert'
+import * as core from '@actions/core'
+import * as exec from '@actions/exec'
+import * as fs from 'fs'
import * as github from '@actions/github'
+import * as io from '@actions/io'
+import * as path from 'path'
import {ReposGetArchiveLinkParams} from '@octokit/rest'
+import {defaultCoreCipherList} from 'constants'
+import {ExecOptions} from '@actions/exec/lib/interfaces'
const IS_WINDOWS = process.platform === 'win32'
@@ -17,13 +25,21 @@ export async function downloadRepository(
repo: repo,
ref: ref
}
+ // todo: retry
const response = await octokit.repos.getArchiveLink(params)
if (response.status != 200) {
throw new Error(
- `GitHub API call failed with response status '${response.status}': ${response.data}`
+ `Unexpected response from GitHub API. Status: '${response.status}'; Data: '${response.data}'`
)
}
console.log(`status=${response.status}`)
console.log(`headers=${JSON.stringify(response.headers)}`)
console.log(`data=${JSON.stringify(typeof response.data)}`)
+ const runnerTemp = process.env['RUNNER_TEMP'] as string
+ assert.ok(runnerTemp, 'RUNNER_TEMP not defined')
+ const archiveFile = path.join(runnerTemp, 'checkout.tar.gz')
+ await fs.promises.writeFile(archiveFile, response.data)
+ await exec.exec(`tar -xzf "${archiveFile}"`, [], {
+ cwd: repositoryPath
+ } as ExecOptions)
}