mirror of
https://github.com/actions/checkout.git
synced 2025-07-13 04:03:52 +00:00
Compare commits
15 Commits
v3.5.1
...
vmjoseph/s
Author | SHA1 | Date | |
---|---|---|---|
af5130cb88 | |||
8e555ec39e | |||
b99f9d0aba | |||
a9f581070e | |||
d2e9d8b595 | |||
25424e8595 | |||
bac1bcfa81 | |||
1f9aeb9f74 | |||
9679ac6b68 | |||
f1764260c3 | |||
9684017cd6 | |||
5788ebd085 | |||
ad19603e6b | |||
2c24b08d98 | |||
9634409d1e |
4
.github/workflows/codeql-analysis.yml
vendored
4
.github/workflows/codeql-analysis.yml
vendored
@ -42,7 +42,7 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v1
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@ -55,4 +55,4 @@ jobs:
|
|||||||
- run: rm -rf dist # We want code scanning to analyze lib instead (individual .js files)
|
- run: rm -rf dist # We want code scanning to analyze lib instead (individual .js files)
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v1
|
||||||
|
11
.github/workflows/update-main-version.yml
vendored
11
.github/workflows/update-main-version.yml
vendored
@ -1,5 +1,5 @@
|
|||||||
name: Update Main Version
|
name: Update Main Version
|
||||||
run-name: Move ${{ github.event.inputs.major_version }} to ${{ github.event.inputs.target }}
|
run-name: Move ${{ github.event.inputs.main_version }} to ${{ github.event.inputs.target }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@ -7,12 +7,11 @@ on:
|
|||||||
target:
|
target:
|
||||||
description: The tag or reference to use
|
description: The tag or reference to use
|
||||||
required: true
|
required: true
|
||||||
major_version:
|
main_version:
|
||||||
type: choice
|
type: choice
|
||||||
description: The major version to update
|
description: The main version to update
|
||||||
options:
|
options:
|
||||||
- v3
|
- v3
|
||||||
- v2
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tag:
|
tag:
|
||||||
@ -26,6 +25,6 @@ jobs:
|
|||||||
git config user.name github-actions
|
git config user.name github-actions
|
||||||
git config user.email github-actions@github.com
|
git config user.email github-actions@github.com
|
||||||
- name: Tag new target
|
- name: Tag new target
|
||||||
run: git tag -f ${{ github.event.inputs.major_version }} ${{ github.event.inputs.target }}
|
run: git tag -f ${{ github.event.inputs.main_version }} ${{ github.event.inputs.target }}
|
||||||
- name: Push new tag
|
- name: Push new tag
|
||||||
run: git push origin ${{ github.event.inputs.major_version }} --force
|
run: git push origin ${{ github.event.inputs.main_version }} --force
|
||||||
|
BIN
.licenses/npm/@actions/github.dep.yml
generated
BIN
.licenses/npm/@actions/github.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-1.0.8.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/http-client-1.0.8.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/io.dep.yml
generated
BIN
.licenses/npm/@actions/io.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/auth-token.dep.yml
generated
BIN
.licenses/npm/@octokit/auth-token.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/endpoint.dep.yml
generated
BIN
.licenses/npm/@octokit/endpoint.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/graphql.dep.yml
generated
BIN
.licenses/npm/@octokit/graphql.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/plugin-paginate-rest.dep.yml
generated
BIN
.licenses/npm/@octokit/plugin-paginate-rest.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/plugin-request-log.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/plugin-request-log.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@octokit/request.dep.yml
generated
BIN
.licenses/npm/@octokit/request.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@octokit/rest.dep.yml
generated
Normal file
BIN
.licenses/npm/@octokit/rest.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@octokit/types.dep.yml
generated
BIN
.licenses/npm/@octokit/types.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@types/node.dep.yml
generated
Normal file
BIN
.licenses/npm/@types/node.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/atob-lite.dep.yml
generated
Normal file
BIN
.licenses/npm/atob-lite.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/before-after-hook.dep.yml
generated
BIN
.licenses/npm/before-after-hook.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/btoa-lite.dep.yml
generated
Normal file
BIN
.licenses/npm/btoa-lite.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/cross-spawn.dep.yml
generated
Normal file
BIN
.licenses/npm/cross-spawn.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/end-of-stream.dep.yml
generated
Normal file
BIN
.licenses/npm/end-of-stream.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/get-stream.dep.yml
generated
Normal file
BIN
.licenses/npm/get-stream.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/is-plain-object.dep.yml
generated
BIN
.licenses/npm/is-plain-object.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/is-stream.dep.yml
generated
Normal file
BIN
.licenses/npm/is-stream.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/isexe.dep.yml
generated
Normal file
BIN
.licenses/npm/isexe.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/isobject.dep.yml
generated
Normal file
BIN
.licenses/npm/isobject.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.get.dep.yml
generated
Normal file
BIN
.licenses/npm/lodash.get.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.set.dep.yml
generated
Normal file
BIN
.licenses/npm/lodash.set.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/lodash.uniq.dep.yml
generated
Normal file
BIN
.licenses/npm/lodash.uniq.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/macos-release.dep.yml
generated
Normal file
BIN
.licenses/npm/macos-release.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/nice-try.dep.yml
generated
Normal file
BIN
.licenses/npm/nice-try.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/node-fetch.dep.yml
generated
BIN
.licenses/npm/node-fetch.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/npm-run-path.dep.yml
generated
Normal file
BIN
.licenses/npm/npm-run-path.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/octokit-pagination-methods.dep.yml
generated
Normal file
BIN
.licenses/npm/octokit-pagination-methods.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/os-name.dep.yml
generated
Normal file
BIN
.licenses/npm/os-name.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/p-finally.dep.yml
generated
Normal file
BIN
.licenses/npm/p-finally.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/path-key.dep.yml
generated
Normal file
BIN
.licenses/npm/path-key.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/pump.dep.yml
generated
Normal file
BIN
.licenses/npm/pump.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/qs.dep.yml
generated
BIN
.licenses/npm/qs.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/semver-5.7.1.dep.yml
generated
Normal file
BIN
.licenses/npm/semver-5.7.1.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/shebang-command.dep.yml
generated
Normal file
BIN
.licenses/npm/shebang-command.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/shebang-regex.dep.yml
generated
Normal file
BIN
.licenses/npm/shebang-regex.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/signal-exit.dep.yml
generated
Normal file
BIN
.licenses/npm/signal-exit.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/strip-eof.dep.yml
generated
Normal file
BIN
.licenses/npm/strip-eof.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/universal-user-agent-5.0.0.dep.yml
generated
Normal file
BIN
.licenses/npm/universal-user-agent-5.0.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/which.dep.yml
generated
Normal file
BIN
.licenses/npm/which.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/windows-release.dep.yml
generated
Normal file
BIN
.licenses/npm/windows-release.dep.yml
generated
Normal file
Binary file not shown.
24
CHANGELOG.md
24
CHANGELOG.md
@ -1,29 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## v3.5.1
|
|
||||||
- [Fix slow checkout on Windows](https://github.com/actions/checkout/pull/1246)
|
|
||||||
|
|
||||||
## v3.5.0
|
|
||||||
* [Add new public key for known_hosts](https://github.com/actions/checkout/pull/1237)
|
|
||||||
|
|
||||||
## v3.4.0
|
|
||||||
- [Upgrade codeql actions to v2](https://github.com/actions/checkout/pull/1209)
|
|
||||||
- [Upgrade dependencies](https://github.com/actions/checkout/pull/1210)
|
|
||||||
- [Upgrade @actions/io](https://github.com/actions/checkout/pull/1225)
|
|
||||||
|
|
||||||
## v3.3.0
|
|
||||||
- [Implement branch list using callbacks from exec function](https://github.com/actions/checkout/pull/1045)
|
|
||||||
- [Add in explicit reference to private checkout options](https://github.com/actions/checkout/pull/1050)
|
|
||||||
- [Fix comment typos (that got added in #770)](https://github.com/actions/checkout/pull/1057)
|
|
||||||
|
|
||||||
## v3.2.0
|
|
||||||
- [Add GitHub Action to perform release](https://github.com/actions/checkout/pull/942)
|
|
||||||
- [Fix status badge](https://github.com/actions/checkout/pull/967)
|
|
||||||
- [Replace datadog/squid with ubuntu/squid Docker image](https://github.com/actions/checkout/pull/1002)
|
|
||||||
- [Wrap pipeline commands for submoduleForeach in quotes](https://github.com/actions/checkout/pull/964)
|
|
||||||
- [Update @actions/io to 1.1.2](https://github.com/actions/checkout/pull/1029)
|
|
||||||
- [Upgrading version to 3.2.0](https://github.com/actions/checkout/pull/1039)
|
|
||||||
|
|
||||||
## v3.1.0
|
## v3.1.0
|
||||||
- [Use @actions/core `saveState` and `getState`](https://github.com/actions/checkout/pull/939)
|
- [Use @actions/core `saveState` and `getState`](https://github.com/actions/checkout/pull/939)
|
||||||
- [Add `github-server-url` input](https://github.com/actions/checkout/pull/922)
|
- [Add `github-server-url` input](https://github.com/actions/checkout/pull/922)
|
||||||
|
@ -155,7 +155,6 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
|
|||||||
repository: my-org/my-tools
|
repository: my-org/my-tools
|
||||||
path: my-tools
|
path: my-tools
|
||||||
```
|
```
|
||||||
> - If your secondary repository is private you will need to add the option noted in [Checkout multiple repos (private)](#Checkout-multiple-repos-private)
|
|
||||||
|
|
||||||
## Checkout multiple repos (nested)
|
## Checkout multiple repos (nested)
|
||||||
|
|
||||||
@ -169,7 +168,6 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
|
|||||||
repository: my-org/my-tools
|
repository: my-org/my-tools
|
||||||
path: my-tools
|
path: my-tools
|
||||||
```
|
```
|
||||||
> - If your secondary repository is private you will need to add the option noted in [Checkout multiple repos (private)](#Checkout-multiple-repos-private)
|
|
||||||
|
|
||||||
## Checkout multiple repos (private)
|
## Checkout multiple repos (private)
|
||||||
|
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
import * as exec from '@actions/exec'
|
|
||||||
import * as fshelper from '../lib/fs-helper'
|
|
||||||
import * as commandManager from '../lib/git-command-manager'
|
|
||||||
|
|
||||||
let git: commandManager.IGitCommandManager
|
|
||||||
let mockExec = jest.fn()
|
|
||||||
|
|
||||||
describe('git-auth-helper tests', () => {
|
|
||||||
beforeAll(async () => {})
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
jest.spyOn(fshelper, 'fileExistsSync').mockImplementation(jest.fn())
|
|
||||||
jest.spyOn(fshelper, 'directoryExistsSync').mockImplementation(jest.fn())
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.restoreAllMocks()
|
|
||||||
})
|
|
||||||
|
|
||||||
afterAll(() => {})
|
|
||||||
|
|
||||||
it('branch list matches', async () => {
|
|
||||||
mockExec.mockImplementation((path, args, options) => {
|
|
||||||
console.log(args, options.listeners.stdout)
|
|
||||||
|
|
||||||
if (args.includes('version')) {
|
|
||||||
options.listeners.stdout(Buffer.from('2.18'))
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.includes('rev-parse')) {
|
|
||||||
options.listeners.stdline(Buffer.from('refs/heads/foo'))
|
|
||||||
options.listeners.stdline(Buffer.from('refs/heads/bar'))
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1
|
|
||||||
})
|
|
||||||
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
|
||||||
const workingDirectory = 'test'
|
|
||||||
const lfs = false
|
|
||||||
git = await commandManager.createCommandManager(workingDirectory, lfs)
|
|
||||||
|
|
||||||
let branches = await git.branchList(false)
|
|
||||||
|
|
||||||
expect(branches).toHaveLength(2)
|
|
||||||
expect(branches.sort()).toEqual(['foo', 'bar'].sort())
|
|
||||||
})
|
|
||||||
|
|
||||||
it('ambiguous ref name output is captured', async () => {
|
|
||||||
mockExec.mockImplementation((path, args, options) => {
|
|
||||||
console.log(args, options.listeners.stdout)
|
|
||||||
|
|
||||||
if (args.includes('version')) {
|
|
||||||
options.listeners.stdout(Buffer.from('2.18'))
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.includes('rev-parse')) {
|
|
||||||
options.listeners.stdline(Buffer.from('refs/heads/foo'))
|
|
||||||
// If refs/tags/v1 and refs/heads/tags/v1 existed on this repository
|
|
||||||
options.listeners.errline(
|
|
||||||
Buffer.from("error: refname 'tags/v1' is ambiguous")
|
|
||||||
)
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1
|
|
||||||
})
|
|
||||||
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
|
|
||||||
const workingDirectory = 'test'
|
|
||||||
const lfs = false
|
|
||||||
git = await commandManager.createCommandManager(workingDirectory, lfs)
|
|
||||||
|
|
||||||
let branches = await git.branchList(false)
|
|
||||||
|
|
||||||
expect(branches).toHaveLength(1)
|
|
||||||
expect(branches.sort()).toEqual(['foo'].sort())
|
|
||||||
})
|
|
||||||
})
|
|
46306
dist/index.js
vendored
46306
dist/index.js
vendored
File diff suppressed because one or more lines are too long
22679
package-lock.json
generated
22679
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "3.5.1",
|
"version": "3.1.0",
|
||||||
"description": "checkout action",
|
"description": "checkout action",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -30,21 +30,21 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/github": "^5.0.0",
|
"@actions/github": "^2.2.0",
|
||||||
"@actions/io": "^1.1.3",
|
"@actions/io": "^1.0.1",
|
||||||
"@actions/tool-cache": "^1.1.2",
|
"@actions/tool-cache": "^1.1.2",
|
||||||
|
"stream": "0.0.2",
|
||||||
"uuid": "^3.3.3"
|
"uuid": "^3.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^12.7.12",
|
"@types/node": "^12.7.12",
|
||||||
"@types/uuid": "^3.4.6",
|
"@types/uuid": "^3.4.6",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
"@typescript-eslint/parser": "^5.1.0",
|
||||||
"@typescript-eslint/parser": "^5.45.0",
|
"@zeit/ncc": "^0.20.5",
|
||||||
"@vercel/ncc": "^0.36.1",
|
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-plugin-github": "^4.3.2",
|
"eslint-plugin-github": "^4.3.2",
|
||||||
"eslint-plugin-jest": "^25.7.0",
|
"eslint-plugin-jest": "^25.2.2",
|
||||||
"jest": "^27.3.0",
|
"jest": "^27.3.0",
|
||||||
"jest-circus": "^27.3.0",
|
"jest-circus": "^27.3.0",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
|
@ -247,7 +247,7 @@ class GitAuthHelper {
|
|||||||
if (this.settings.sshKnownHosts) {
|
if (this.settings.sshKnownHosts) {
|
||||||
knownHosts += `# Begin from input known hosts\n${this.settings.sshKnownHosts}\n# end from input known hosts\n`
|
knownHosts += `# Begin from input known hosts\n${this.settings.sshKnownHosts}\n# end from input known hosts\n`
|
||||||
}
|
}
|
||||||
knownHosts += `# Begin implicitly added github.com\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n# End implicitly added github.com\n`
|
knownHosts += `# Begin implicitly added github.com\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==\n# End implicitly added github.com\n`
|
||||||
this.sshKnownHostsPath = path.join(runnerTemp, `${uniqueId}_known_hosts`)
|
this.sshKnownHostsPath = path.join(runnerTemp, `${uniqueId}_known_hosts`)
|
||||||
stateHelper.setSshKnownHostsPath(this.sshKnownHostsPath)
|
stateHelper.setSshKnownHostsPath(this.sshKnownHostsPath)
|
||||||
await fs.promises.writeFile(this.sshKnownHostsPath, knownHosts)
|
await fs.promises.writeFile(this.sshKnownHostsPath, knownHosts)
|
||||||
|
@ -7,6 +7,7 @@ import * as refHelper from './ref-helper'
|
|||||||
import * as regexpHelper from './regexp-helper'
|
import * as regexpHelper from './regexp-helper'
|
||||||
import * as retryHelper from './retry-helper'
|
import * as retryHelper from './retry-helper'
|
||||||
import {GitVersion} from './git-version'
|
import {GitVersion} from './git-version'
|
||||||
|
import stream, {Writable} from 'stream'
|
||||||
|
|
||||||
// Auth header not supported before 2.9
|
// Auth header not supported before 2.9
|
||||||
// Wire protocol v2 not supported before 2.18
|
// Wire protocol v2 not supported before 2.18
|
||||||
@ -91,14 +92,12 @@ class GitCommandManager {
|
|||||||
|
|
||||||
async branchList(remote: boolean): Promise<string[]> {
|
async branchList(remote: boolean): Promise<string[]> {
|
||||||
const result: string[] = []
|
const result: string[] = []
|
||||||
|
const stderr: string[] = []
|
||||||
|
|
||||||
// Note, this implementation uses "rev-parse --symbolic-full-name" because the output from
|
// Note, this implementation uses "rev-parse --symbolic-full-name" because the output from
|
||||||
// "branch --list" is more difficult when in a detached HEAD state.
|
// "branch --list" is more difficult when in a detached HEAD state.
|
||||||
|
// Note, this implementation uses "rev-parse --symbolic-full-name" because there is a bug
|
||||||
// TODO(https://github.com/actions/checkout/issues/786): this implementation uses
|
// in Git 2.18 that causes "rev-parse --symbolic" to output symbolic full names.
|
||||||
// "rev-parse --symbolic-full-name" because there is a bug
|
|
||||||
// in Git 2.18 that causes "rev-parse --symbolic" to output symbolic full names. When
|
|
||||||
// 2.18 is no longer supported, we can switch back to --symbolic.
|
|
||||||
|
|
||||||
const args = ['rev-parse', '--symbolic-full-name']
|
const args = ['rev-parse', '--symbolic-full-name']
|
||||||
if (remote) {
|
if (remote) {
|
||||||
@ -107,49 +106,29 @@ class GitCommandManager {
|
|||||||
args.push('--branches')
|
args.push('--branches')
|
||||||
}
|
}
|
||||||
|
|
||||||
const stderr: string[] = []
|
|
||||||
const errline: string[] = []
|
|
||||||
const stdout: string[] = []
|
|
||||||
const stdline: string[] = []
|
|
||||||
|
|
||||||
const listeners = {
|
const listeners = {
|
||||||
stderr: (data: Buffer) => {
|
stderr: (data: Buffer) => {
|
||||||
stderr.push(data.toString())
|
stderr.push(data.toString())
|
||||||
},
|
},
|
||||||
errline: (data: Buffer) => {
|
errline: (line: string) => {
|
||||||
errline.push(data.toString())
|
stderr.push(line)
|
||||||
},
|
|
||||||
stdout: (data: Buffer) => {
|
|
||||||
stdout.push(data.toString())
|
|
||||||
},
|
|
||||||
stdline: (data: Buffer) => {
|
|
||||||
stdline.push(data.toString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const output = await this.execGit(args, false, false, listeners)
|
||||||
|
|
||||||
// Suppress the output in order to avoid flooding annotations with innocuous errors.
|
for (let branch of output.stdout.trim().split('\n')) {
|
||||||
await this.execGit(args, false, true, listeners)
|
|
||||||
|
|
||||||
core.debug(`stderr callback is: ${stderr}`)
|
|
||||||
core.debug(`errline callback is: ${errline}`)
|
|
||||||
core.debug(`stdout callback is: ${stdout}`)
|
|
||||||
core.debug(`stdline callback is: ${stdline}`)
|
|
||||||
|
|
||||||
for (let branch of stdline) {
|
|
||||||
branch = branch.trim()
|
branch = branch.trim()
|
||||||
if (!branch) {
|
if (branch) {
|
||||||
continue
|
if (branch.startsWith('refs/heads/')) {
|
||||||
}
|
branch = branch.substr('refs/heads/'.length)
|
||||||
|
} else if (branch.startsWith('refs/remotes/')) {
|
||||||
|
branch = branch.substr('refs/remotes/'.length)
|
||||||
|
}
|
||||||
|
|
||||||
if (branch.startsWith('refs/heads/')) {
|
result.push(branch)
|
||||||
branch = branch.substring('refs/heads/'.length)
|
|
||||||
} else if (branch.startsWith('refs/remotes/')) {
|
|
||||||
branch = branch.substring('refs/remotes/'.length)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.push(branch)
|
|
||||||
}
|
}
|
||||||
|
core.info(stderr.join('\n'))
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,30 +419,45 @@ class GitCommandManager {
|
|||||||
for (const key of Object.keys(this.gitEnv)) {
|
for (const key of Object.keys(this.gitEnv)) {
|
||||||
env[key] = this.gitEnv[key]
|
env[key] = this.gitEnv[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultListener = {
|
const defaultListener = {
|
||||||
stdout: (data: Buffer) => {
|
stdout: (data: Buffer) => {
|
||||||
stdout.push(data.toString())
|
stdout.push(data.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// const listeners = Object.keys(customListeners) < 0 ? customListeners : {stdout: (data: Buffer) => {
|
||||||
const mergedListeners = {...defaultListener, ...customListeners}
|
// stdout.push(data.toString())
|
||||||
|
// }}
|
||||||
|
const listenersD = {...customListeners, ...defaultListener}
|
||||||
const stdout: string[] = []
|
const stdout: string[] = []
|
||||||
|
// let temp = ''
|
||||||
|
// let temp2 = ''
|
||||||
const options = {
|
const options = {
|
||||||
cwd: this.workingDirectory,
|
cwd: this.workingDirectory,
|
||||||
env,
|
env,
|
||||||
silent,
|
silent,
|
||||||
ignoreReturnCode: allowAllExitCodes,
|
ignoreReturnCode: allowAllExitCodes,
|
||||||
listeners: mergedListeners
|
listeners: listenersD
|
||||||
|
// ,
|
||||||
|
// errStream: new stream.Writable({
|
||||||
|
// write(chunk, _, next) {
|
||||||
|
// temp += chunk.toString()
|
||||||
|
// next()
|
||||||
|
// }
|
||||||
|
// }),
|
||||||
|
|
||||||
|
// outStream: new stream.Writable({
|
||||||
|
// write(chunk, _, next) {
|
||||||
|
// temp2 += chunk.toString()
|
||||||
|
// next()
|
||||||
|
// }
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
result.exitCode = await exec.exec(`"${this.gitPath}"`, args, options)
|
result.exitCode = await exec.exec(`"${this.gitPath}"`, args, options)
|
||||||
result.stdout = stdout.join('')
|
result.stdout = stdout.join('')
|
||||||
|
// core.info(temp.length.toString())
|
||||||
core.debug(result.exitCode.toString())
|
// core.info(temp2.length.toString())
|
||||||
core.debug(result.stdout)
|
core.info(result.stdout)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import * as assert from 'assert'
|
import * as assert from 'assert'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as github from '@actions/github'
|
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as retryHelper from './retry-helper'
|
import * as retryHelper from './retry-helper'
|
||||||
import * as toolCache from '@actions/tool-cache'
|
import * as toolCache from '@actions/tool-cache'
|
||||||
import {default as uuid} from 'uuid/v4'
|
import {default as uuid} from 'uuid/v4'
|
||||||
|
import {getOctokit, Octokit} from './octokit-provider'
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
|
|
||||||
@ -84,11 +84,11 @@ export async function getDefaultBranch(
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return await retryHelper.execute(async () => {
|
return await retryHelper.execute(async () => {
|
||||||
core.info('Retrieving the default branch name')
|
core.info('Retrieving the default branch name')
|
||||||
const octokit = github.getOctokit(authToken, {baseUrl: baseUrl})
|
const octokit = getOctokit(authToken, {baseUrl: baseUrl})
|
||||||
let result: string
|
let result: string
|
||||||
try {
|
try {
|
||||||
// Get the default branch from the repo info
|
// Get the default branch from the repo info
|
||||||
const response = await octokit.rest.repos.get({owner, repo})
|
const response = await octokit.repos.get({owner, repo})
|
||||||
result = response.data.default_branch
|
result = response.data.default_branch
|
||||||
assert.ok(result, 'default_branch cannot be empty')
|
assert.ok(result, 'default_branch cannot be empty')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -125,14 +125,19 @@ async function downloadArchive(
|
|||||||
commit: string,
|
commit: string,
|
||||||
baseUrl?: string
|
baseUrl?: string
|
||||||
): Promise<Buffer> {
|
): Promise<Buffer> {
|
||||||
const octokit = github.getOctokit(authToken, {baseUrl: baseUrl})
|
const octokit = getOctokit(authToken, {baseUrl: baseUrl})
|
||||||
const download = IS_WINDOWS
|
const params: Octokit.ReposGetArchiveLinkParams = {
|
||||||
? octokit.rest.repos.downloadZipballArchive
|
|
||||||
: octokit.rest.repos.downloadTarballArchive
|
|
||||||
const response = await download({
|
|
||||||
owner: owner,
|
owner: owner,
|
||||||
repo: repo,
|
repo: repo,
|
||||||
|
archive_format: IS_WINDOWS ? 'zipball' : 'tarball',
|
||||||
ref: commit || ref
|
ref: commit || ref
|
||||||
})
|
}
|
||||||
return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer
|
const response = await octokit.repos.getArchiveLink(params)
|
||||||
|
if (response.status != 200) {
|
||||||
|
throw new Error(
|
||||||
|
`Unexpected response from GitHub API. Status: ${response.status}, Data: ${response.data}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Buffer.from(response.data) // response.data is ArrayBuffer
|
||||||
}
|
}
|
||||||
|
23
src/octokit-provider.ts
Normal file
23
src/octokit-provider.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import * as github from '@actions/github'
|
||||||
|
import {Octokit} from '@octokit/rest'
|
||||||
|
import {getServerApiUrl} from './url-helper'
|
||||||
|
|
||||||
|
// Centralize all Octokit references by re-exporting
|
||||||
|
export {Octokit} from '@octokit/rest'
|
||||||
|
|
||||||
|
export type OctokitOptions = {
|
||||||
|
baseUrl?: string
|
||||||
|
userAgent?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getOctokit(authToken: string, opts: OctokitOptions) {
|
||||||
|
const options: Octokit.Options = {
|
||||||
|
baseUrl: getServerApiUrl(opts.baseUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.userAgent) {
|
||||||
|
options.userAgent = opts.userAgent
|
||||||
|
}
|
||||||
|
|
||||||
|
return new github.GitHub(authToken, options)
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import {IGitCommandManager} from './git-command-manager'
|
import {IGitCommandManager} from './git-command-manager'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
|
import {getOctokit} from './octokit-provider'
|
||||||
import {isGhes} from './url-helper'
|
import {isGhes} from './url-helper'
|
||||||
|
|
||||||
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
||||||
@ -244,7 +245,7 @@ export async function checkCommitInfo(
|
|||||||
core.debug(
|
core.debug(
|
||||||
`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`
|
`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`
|
||||||
)
|
)
|
||||||
const octokit = github.getOctokit(token, {
|
const octokit = getOctokit(token, {
|
||||||
baseUrl: baseUrl,
|
baseUrl: baseUrl,
|
||||||
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload(
|
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload(
|
||||||
'number'
|
'number'
|
||||||
@ -252,10 +253,7 @@ export async function checkCommitInfo(
|
|||||||
process.env['GITHUB_RUN_ID']
|
process.env['GITHUB_RUN_ID']
|
||||||
};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
|
};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
|
||||||
})
|
})
|
||||||
await octokit.rest.repos.get({
|
await octokit.repos.get({owner: repositoryOwner, repo: repositoryName})
|
||||||
owner: repositoryOwner,
|
|
||||||
repo: repositoryName
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.debug(
|
core.debug(
|
||||||
|
@ -47,7 +47,7 @@ export function setSshKnownHostsPath(sshKnownHostsPath: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the set-safe-directory input so the POST action can retrieve the value.
|
* Save the sef-safe-directory input so the POST action can retrieve the value.
|
||||||
*/
|
*/
|
||||||
export function setSafeDirectory() {
|
export function setSafeDirectory() {
|
||||||
core.saveState('setSafeDirectory', 'true')
|
core.saveState('setSafeDirectory', 'true')
|
||||||
|
Reference in New Issue
Block a user