Compare commits
	
		
			6 Commits
		
	
	
		
			fhammerl/r
			...
			luketomlin
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					719fedec20 | ||
| 
						 | 
					f095bcc56b | ||
| 
						 | 
					47fbe2df0a | ||
| 
						 | 
					8e5e7e5ab8 | ||
| 
						 | 
					eb35239ec2 | ||
| 
						 | 
					83b7061638 | 
@@ -1,5 +1,14 @@
 | 
			
		||||
# Changelog
 | 
			
		||||
 | 
			
		||||
## v3.5.2
 | 
			
		||||
- [Fix api endpoint for GHES](https://github.com/actions/checkout/pull/1289)
 | 
			
		||||
 | 
			
		||||
## 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)
 | 
			
		||||
 
 | 
			
		||||
@@ -770,6 +770,9 @@ async function setup(testName: string): Promise<void> {
 | 
			
		||||
      return ''
 | 
			
		||||
    }),
 | 
			
		||||
    submoduleSync: jest.fn(),
 | 
			
		||||
    submoduleStatus: jest.fn(async () => {
 | 
			
		||||
      return true
 | 
			
		||||
    }),
 | 
			
		||||
    submoduleUpdate: jest.fn(),
 | 
			
		||||
    tagExists: jest.fn(),
 | 
			
		||||
    tryClean: jest.fn(),
 | 
			
		||||
 
 | 
			
		||||
@@ -281,6 +281,65 @@ describe('git-directory-helper tests', () => {
 | 
			
		||||
    expect(git.branchDelete).toHaveBeenCalledWith(false, 'local-branch-2')
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  const cleanWhenSubmoduleStatusIsFalse =
 | 
			
		||||
    'cleans when submodule status is false'
 | 
			
		||||
 | 
			
		||||
  it(cleanWhenSubmoduleStatusIsFalse, async () => {
 | 
			
		||||
    // Arrange
 | 
			
		||||
    await setup(cleanWhenSubmoduleStatusIsFalse)
 | 
			
		||||
    await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
 | 
			
		||||
 | 
			
		||||
    //mock bad submodule
 | 
			
		||||
 | 
			
		||||
    const submoduleStatus = git.submoduleStatus as jest.Mock<any, any>
 | 
			
		||||
    submoduleStatus.mockImplementation(async (remote: boolean) => {
 | 
			
		||||
      return false
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    // Act
 | 
			
		||||
    await gitDirectoryHelper.prepareExistingDirectory(
 | 
			
		||||
      git,
 | 
			
		||||
      repositoryPath,
 | 
			
		||||
      repositoryUrl,
 | 
			
		||||
      clean,
 | 
			
		||||
      ref
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    // Assert
 | 
			
		||||
    const files = await fs.promises.readdir(repositoryPath)
 | 
			
		||||
    expect(files).toHaveLength(0)
 | 
			
		||||
    expect(git.tryClean).toHaveBeenCalled()
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  const doesNotCleanWhenSubmoduleStatusIsTrue =
 | 
			
		||||
    'does not clean when submodule status is true'
 | 
			
		||||
 | 
			
		||||
  it(doesNotCleanWhenSubmoduleStatusIsTrue, async () => {
 | 
			
		||||
    // Arrange
 | 
			
		||||
    await setup(doesNotCleanWhenSubmoduleStatusIsTrue)
 | 
			
		||||
    await fs.promises.writeFile(path.join(repositoryPath, 'my-file'), '')
 | 
			
		||||
 | 
			
		||||
    const submoduleStatus = git.submoduleStatus as jest.Mock<any, any>
 | 
			
		||||
    submoduleStatus.mockImplementation(async (remote: boolean) => {
 | 
			
		||||
      return true
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    // Act
 | 
			
		||||
    await gitDirectoryHelper.prepareExistingDirectory(
 | 
			
		||||
      git,
 | 
			
		||||
      repositoryPath,
 | 
			
		||||
      repositoryUrl,
 | 
			
		||||
      clean,
 | 
			
		||||
      ref
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    // Assert
 | 
			
		||||
 | 
			
		||||
    const files = await fs.promises.readdir(repositoryPath)
 | 
			
		||||
    expect(files.sort()).toEqual(['.git', 'my-file'])
 | 
			
		||||
    expect(git.tryClean).toHaveBeenCalled()
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  const removesLockFiles = 'removes lock files'
 | 
			
		||||
  it(removesLockFiles, async () => {
 | 
			
		||||
    // Arrange
 | 
			
		||||
@@ -423,6 +482,9 @@ async function setup(testName: string): Promise<void> {
 | 
			
		||||
    submoduleForeach: jest.fn(),
 | 
			
		||||
    submoduleSync: jest.fn(),
 | 
			
		||||
    submoduleUpdate: jest.fn(),
 | 
			
		||||
    submoduleStatus: jest.fn(async () => {
 | 
			
		||||
      return true
 | 
			
		||||
    }),
 | 
			
		||||
    tagExists: jest.fn(),
 | 
			
		||||
    tryClean: jest.fn(async () => {
 | 
			
		||||
      return true
 | 
			
		||||
 
 | 
			
		||||
@@ -181,7 +181,7 @@ GITHUB_WORKSPACE=/home/runner/work/foo/foo
 | 
			
		||||
RUNNER_WORKSPACE=/home/runner/work/foo
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
V2 introduces a new contraint on the checkout path. The location must now be under `github.workspace`. Whereas the checkout@v1 constraint was one level up, under `runner.workspace`.
 | 
			
		||||
V2 introduces a new constraint on the checkout path. The location must now be under `github.workspace`. Whereas the checkout@v1 constraint was one level up, under `runner.workspace`.
 | 
			
		||||
 | 
			
		||||
V2 no longer changes `github.workspace` to follow wherever the self repo is checked-out.
 | 
			
		||||
 | 
			
		||||
@@ -287,4 +287,4 @@ Note:
 | 
			
		||||
- Update samples to consume `actions/checkout@v2`
 | 
			
		||||
- Job containers now require git in the PATH for checkout, otherwise fallback to REST API
 | 
			
		||||
- Minimum git version 2.18
 | 
			
		||||
- Update problem matcher logic regarding source file verification (runner)
 | 
			
		||||
- Update problem matcher logic regarding source file verification (runner)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										39
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							@@ -722,6 +722,18 @@ class GitCommandManager {
 | 
			
		||||
            return output.stdout.trim();
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * Lists SHAs pointed to by a revision.
 | 
			
		||||
     * @param {string} ref  For example: 'refs/heads/main' or '/refs/tags/v1'
 | 
			
		||||
     * @param {number} numberOfRefs
 | 
			
		||||
     * @param value
 | 
			
		||||
     */
 | 
			
		||||
    revList(ref, numberOfRefs) {
 | 
			
		||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
            const output = yield this.execGit(['rev-list', ref, `-${numberOfRefs}`]);
 | 
			
		||||
            return output.stdout.trim();
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    setEnvironmentVariable(name, value) {
 | 
			
		||||
        this.gitEnv[name] = value;
 | 
			
		||||
    }
 | 
			
		||||
@@ -765,6 +777,13 @@ class GitCommandManager {
 | 
			
		||||
            yield this.execGit(args);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    submoduleStatus() {
 | 
			
		||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
            const output = yield this.execGit(['submodule', 'status'], true);
 | 
			
		||||
            core.debug(output.stdout);
 | 
			
		||||
            return output.exitCode === 0;
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    tagExists(pattern) {
 | 
			
		||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
            const output = yield this.execGit(['tag', '--list', pattern]);
 | 
			
		||||
@@ -1023,11 +1042,16 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean, ref
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                core.endGroup();
 | 
			
		||||
                // Check for submodules and delete any existing files if submodules are present
 | 
			
		||||
                if (!(yield git.submoduleStatus())) {
 | 
			
		||||
                    remove = true;
 | 
			
		||||
                    core.info('Bad Submodules found, removing existing files');
 | 
			
		||||
                }
 | 
			
		||||
                // Clean
 | 
			
		||||
                if (clean) {
 | 
			
		||||
                    core.startGroup('Cleaning the repository');
 | 
			
		||||
                    if (!(yield git.tryClean())) {
 | 
			
		||||
                        core.debug(`The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For futher investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`);
 | 
			
		||||
                        core.debug(`The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For further investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`);
 | 
			
		||||
                        remove = true;
 | 
			
		||||
                    }
 | 
			
		||||
                    else if (!(yield git.tryReset())) {
 | 
			
		||||
@@ -1453,6 +1477,7 @@ const path = __importStar(__nccwpck_require__(1017));
 | 
			
		||||
const retryHelper = __importStar(__nccwpck_require__(2155));
 | 
			
		||||
const toolCache = __importStar(__nccwpck_require__(7784));
 | 
			
		||||
const v4_1 = __importDefault(__nccwpck_require__(824));
 | 
			
		||||
const url_helper_1 = __nccwpck_require__(9437);
 | 
			
		||||
const IS_WINDOWS = process.platform === 'win32';
 | 
			
		||||
function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath, baseUrl) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
@@ -1513,7 +1538,9 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) {
 | 
			
		||||
        return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
            var _a;
 | 
			
		||||
            core.info('Retrieving the default branch name');
 | 
			
		||||
            const octokit = github.getOctokit(authToken, { baseUrl: baseUrl });
 | 
			
		||||
            const octokit = github.getOctokit(authToken, {
 | 
			
		||||
                baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl)
 | 
			
		||||
            });
 | 
			
		||||
            let result;
 | 
			
		||||
            try {
 | 
			
		||||
                // Get the default branch from the repo info
 | 
			
		||||
@@ -1545,7 +1572,9 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) {
 | 
			
		||||
exports.getDefaultBranch = getDefaultBranch;
 | 
			
		||||
function downloadArchive(authToken, owner, repo, ref, commit, baseUrl) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        const octokit = github.getOctokit(authToken, { baseUrl: baseUrl });
 | 
			
		||||
        const octokit = github.getOctokit(authToken, {
 | 
			
		||||
            baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl)
 | 
			
		||||
        });
 | 
			
		||||
        const download = IS_WINDOWS
 | 
			
		||||
            ? octokit.rest.repos.downloadZipballArchive
 | 
			
		||||
            : octokit.rest.repos.downloadTarballArchive;
 | 
			
		||||
@@ -1965,7 +1994,7 @@ function testRef(git, ref, commit) {
 | 
			
		||||
        // refs/tags/
 | 
			
		||||
        else if (upperRef.startsWith('REFS/TAGS/')) {
 | 
			
		||||
            const tagName = ref.substring('refs/tags/'.length);
 | 
			
		||||
            return ((yield git.tagExists(tagName)) && commit === (yield git.revParse(ref)));
 | 
			
		||||
            return ((yield git.tagExists(tagName)) && commit === (yield git.revList(ref, 1)));
 | 
			
		||||
        }
 | 
			
		||||
        // Unexpected
 | 
			
		||||
        else {
 | 
			
		||||
@@ -2026,7 +2055,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref
 | 
			
		||||
            if (actualHeadSha !== expectedHeadSha) {
 | 
			
		||||
                core.debug(`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`);
 | 
			
		||||
                const octokit = github.getOctokit(token, {
 | 
			
		||||
                    baseUrl: baseUrl,
 | 
			
		||||
                    baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl),
 | 
			
		||||
                    userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload('number')};run_id=${process.env['GITHUB_RUN_ID']};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
 | 
			
		||||
                });
 | 
			
		||||
                yield octokit.rest.repos.get({
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1,12 +1,12 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "checkout",
 | 
			
		||||
  "version": "3.2.0",
 | 
			
		||||
  "version": "3.5.2",
 | 
			
		||||
  "lockfileVersion": 2,
 | 
			
		||||
  "requires": true,
 | 
			
		||||
  "packages": {
 | 
			
		||||
    "": {
 | 
			
		||||
      "name": "checkout",
 | 
			
		||||
      "version": "3.2.0",
 | 
			
		||||
      "version": "3.5.2",
 | 
			
		||||
      "license": "MIT",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "@actions/core": "^1.10.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "checkout",
 | 
			
		||||
  "version": "3.2.0",
 | 
			
		||||
  "version": "3.5.2",
 | 
			
		||||
  "description": "checkout action",
 | 
			
		||||
  "main": "lib/main.js",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
 
 | 
			
		||||
@@ -35,12 +35,14 @@ export interface IGitCommandManager {
 | 
			
		||||
  log1(format?: string): Promise<string>
 | 
			
		||||
  remoteAdd(remoteName: string, remoteUrl: string): Promise<void>
 | 
			
		||||
  removeEnvironmentVariable(name: string): void
 | 
			
		||||
  revList(ref: string, numberOfRefs: number): Promise<string>
 | 
			
		||||
  revParse(ref: string): Promise<string>
 | 
			
		||||
  setEnvironmentVariable(name: string, value: string): void
 | 
			
		||||
  shaExists(sha: string): Promise<boolean>
 | 
			
		||||
  submoduleForeach(command: string, recursive: boolean): Promise<string>
 | 
			
		||||
  submoduleSync(recursive: boolean): Promise<void>
 | 
			
		||||
  submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void>
 | 
			
		||||
  submoduleStatus(): Promise<boolean>
 | 
			
		||||
  tagExists(pattern: string): Promise<boolean>
 | 
			
		||||
  tryClean(): Promise<boolean>
 | 
			
		||||
  tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
 | 
			
		||||
@@ -313,6 +315,17 @@ class GitCommandManager {
 | 
			
		||||
    return output.stdout.trim()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Lists SHAs pointed to by a revision.
 | 
			
		||||
   * @param {string} ref  For example: 'refs/heads/main' or '/refs/tags/v1'
 | 
			
		||||
   * @param {number} numberOfRefs
 | 
			
		||||
   * @param value
 | 
			
		||||
   */
 | 
			
		||||
  async revList(ref: string, numberOfRefs: number): Promise<string> {
 | 
			
		||||
    const output = await this.execGit(['rev-list', ref, `-${numberOfRefs}`])
 | 
			
		||||
    return output.stdout.trim()
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  setEnvironmentVariable(name: string, value: string): void {
 | 
			
		||||
    this.gitEnv[name] = value
 | 
			
		||||
  }
 | 
			
		||||
@@ -357,6 +370,12 @@ class GitCommandManager {
 | 
			
		||||
    await this.execGit(args)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async submoduleStatus(): Promise<boolean> {
 | 
			
		||||
    const output = await this.execGit(['submodule', 'status'], true)
 | 
			
		||||
    core.debug(output.stdout)
 | 
			
		||||
    return output.exitCode === 0
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async tagExists(pattern: string): Promise<boolean> {
 | 
			
		||||
    const output = await this.execGit(['tag', '--list', pattern])
 | 
			
		||||
    return !!output.stdout.trim()
 | 
			
		||||
 
 | 
			
		||||
@@ -81,12 +81,18 @@ export async function prepareExistingDirectory(
 | 
			
		||||
      }
 | 
			
		||||
      core.endGroup()
 | 
			
		||||
 | 
			
		||||
      // Check for submodules and delete any existing files if submodules are present
 | 
			
		||||
      if (!(await git.submoduleStatus())) {
 | 
			
		||||
        remove = true
 | 
			
		||||
        core.info('Bad Submodules found, removing existing files')
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // Clean
 | 
			
		||||
      if (clean) {
 | 
			
		||||
        core.startGroup('Cleaning the repository')
 | 
			
		||||
        if (!(await git.tryClean())) {
 | 
			
		||||
          core.debug(
 | 
			
		||||
            `The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For futher investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`
 | 
			
		||||
            `The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For further investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`
 | 
			
		||||
          )
 | 
			
		||||
          remove = true
 | 
			
		||||
        } else if (!(await git.tryReset())) {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ import * as path from 'path'
 | 
			
		||||
import * as retryHelper from './retry-helper'
 | 
			
		||||
import * as toolCache from '@actions/tool-cache'
 | 
			
		||||
import {default as uuid} from 'uuid/v4'
 | 
			
		||||
import {getServerApiUrl} from './url-helper'
 | 
			
		||||
 | 
			
		||||
const IS_WINDOWS = process.platform === 'win32'
 | 
			
		||||
 | 
			
		||||
@@ -84,7 +85,9 @@ export async function getDefaultBranch(
 | 
			
		||||
): Promise<string> {
 | 
			
		||||
  return await retryHelper.execute(async () => {
 | 
			
		||||
    core.info('Retrieving the default branch name')
 | 
			
		||||
    const octokit = github.getOctokit(authToken, {baseUrl: baseUrl})
 | 
			
		||||
    const octokit = github.getOctokit(authToken, {
 | 
			
		||||
      baseUrl: getServerApiUrl(baseUrl)
 | 
			
		||||
    })
 | 
			
		||||
    let result: string
 | 
			
		||||
    try {
 | 
			
		||||
      // Get the default branch from the repo info
 | 
			
		||||
@@ -125,7 +128,9 @@ async function downloadArchive(
 | 
			
		||||
  commit: string,
 | 
			
		||||
  baseUrl?: string
 | 
			
		||||
): Promise<Buffer> {
 | 
			
		||||
  const octokit = github.getOctokit(authToken, {baseUrl: baseUrl})
 | 
			
		||||
  const octokit = github.getOctokit(authToken, {
 | 
			
		||||
    baseUrl: getServerApiUrl(baseUrl)
 | 
			
		||||
  })
 | 
			
		||||
  const download = IS_WINDOWS
 | 
			
		||||
    ? octokit.rest.repos.downloadZipballArchive
 | 
			
		||||
    : octokit.rest.repos.downloadTarballArchive
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
import {IGitCommandManager} from './git-command-manager'
 | 
			
		||||
import * as core from '@actions/core'
 | 
			
		||||
import * as github from '@actions/github'
 | 
			
		||||
import {isGhes} from './url-helper'
 | 
			
		||||
import {getServerApiUrl, isGhes} from './url-helper'
 | 
			
		||||
 | 
			
		||||
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
 | 
			
		||||
 | 
			
		||||
@@ -167,7 +167,7 @@ export async function testRef(
 | 
			
		||||
  else if (upperRef.startsWith('REFS/TAGS/')) {
 | 
			
		||||
    const tagName = ref.substring('refs/tags/'.length)
 | 
			
		||||
    return (
 | 
			
		||||
      (await git.tagExists(tagName)) && commit === (await git.revParse(ref))
 | 
			
		||||
      (await git.tagExists(tagName)) && commit === (await git.revList(ref, 1))
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
  // Unexpected
 | 
			
		||||
@@ -245,7 +245,7 @@ export async function checkCommitInfo(
 | 
			
		||||
        `Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`
 | 
			
		||||
      )
 | 
			
		||||
      const octokit = github.getOctokit(token, {
 | 
			
		||||
        baseUrl: baseUrl,
 | 
			
		||||
        baseUrl: getServerApiUrl(baseUrl),
 | 
			
		||||
        userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload(
 | 
			
		||||
          'number'
 | 
			
		||||
        )};run_id=${
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user