From 8926c30a300957ac926a8e063bdd0f6454163b5c Mon Sep 17 00:00:00 2001 From: John Wesley Walker III <81404201+jww3@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:16:35 +0100 Subject: [PATCH 1/5] In consideration of a future v5, update minimum git version. --- src/git-command-manager.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index 0f3fd25af..f4cb01c24 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -11,7 +11,8 @@ 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') +// sparse-checkout not supported before 2.27 +export const MinimumGitVersion = new GitVersion('2.27') export interface IGitCommandManager { branchDelete(remote: boolean, branch: string): Promise From db715dc5a417ac6a6259bcb9f42b96ff8725efc0 Mon Sep 17 00:00:00 2001 From: John Wesley Walker III <81404201+jww3@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:28:10 +0100 Subject: [PATCH 2/5] Update git-command-manager.ts --- src/git-command-manager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index f4cb01c24..0adc732b0 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -11,8 +11,8 @@ import {GitVersion} from './git-version' // Auth header not supported before 2.9 // Wire protocol v2 not supported before 2.18 -// sparse-checkout not supported before 2.27 -export const MinimumGitVersion = new GitVersion('2.27') +// sparse-checkout not supported before 2.25 +export const MinimumGitVersion = new GitVersion('2.25') export interface IGitCommandManager { branchDelete(remote: boolean, branch: string): Promise From 06abf5564ef25ba2e948ab872e0baedf5dd84c2e Mon Sep 17 00:00:00 2001 From: John Wesley Walker III <81404201+jww3@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:52:48 +0000 Subject: [PATCH 3/5] ran `npm run build` --- dist/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 13896027d..d66b9a716 100644 --- a/dist/index.js +++ b/dist/index.js @@ -480,7 +480,8 @@ const retryHelper = __importStar(__nccwpck_require__(2155)); const git_version_1 = __nccwpck_require__(3142); // Auth header not supported before 2.9 // Wire protocol v2 not supported before 2.18 -exports.MinimumGitVersion = new git_version_1.GitVersion('2.18'); +// sparse-checkout not supported before 2.25 +exports.MinimumGitVersion = new git_version_1.GitVersion('2.25'); function createCommandManager(workingDirectory, lfs, doSparseCheckout) { return __awaiter(this, void 0, void 0, function* () { return yield GitCommandManager.createCommandManager(workingDirectory, lfs, doSparseCheckout); From 64dbc8124d5d4f8bc6b701db3cde44f01e8b816f Mon Sep 17 00:00:00 2001 From: John Wesley Walker III <81404201+jww3@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:25:38 +0000 Subject: [PATCH 4/5] updated other version-specific logic --- README.md | 2 +- __test__/git-command-manager.test.ts | 6 +++--- dist/index.js | 8 +------- src/git-command-manager.ts | 11 +---------- 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index bfecf464d..2858d4651 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Only a single commit is fetched by default, for the ref/SHA that triggered the w The auth token is persisted in the local git config. This enables your scripts to run authenticated git commands. The token is removed during post-job cleanup. Set `persist-credentials: false` to opt-out. -When Git 2.18 or higher is not in your PATH, falls back to the REST API to download the files. +When Git 2.25 or higher is not in your PATH, falls back to the REST API to download the files. # What's new diff --git a/__test__/git-command-manager.test.ts b/__test__/git-command-manager.test.ts index cea73d4dd..fcffe04e4 100644 --- a/__test__/git-command-manager.test.ts +++ b/__test__/git-command-manager.test.ts @@ -24,7 +24,7 @@ describe('git-auth-helper tests', () => { console.log(args, options.listeners.stdout) if (args.includes('version')) { - options.listeners.stdout(Buffer.from('2.18')) + options.listeners.stdout(Buffer.from('2.25')) return 0 } @@ -57,7 +57,7 @@ describe('git-auth-helper tests', () => { console.log(args, options.listeners.stdout) if (args.includes('version')) { - options.listeners.stdout(Buffer.from('2.18')) + options.listeners.stdout(Buffer.from('2.25')) return 0 } @@ -97,7 +97,7 @@ describe('Test fetchDepth and fetchTags options', () => { console.log(args, options.listeners.stdout) if (args.includes('version')) { - options.listeners.stdout(Buffer.from('2.18')) + options.listeners.stdout(Buffer.from('2.25')) } return 0 diff --git a/dist/index.js b/dist/index.js index d66b9a716..42e029761 100644 --- a/dist/index.js +++ b/dist/index.js @@ -524,13 +524,7 @@ class GitCommandManager { branchList(remote) { return __awaiter(this, void 0, void 0, function* () { const result = []; - // Note, this implementation uses "rev-parse --symbolic-full-name" because the output from - // "branch --list" is more difficult when in a detached HEAD state. - // TODO(https://github.com/actions/checkout/issues/786): this implementation uses - // "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']; if (remote) { args.push('--remotes=origin'); } diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index 0adc732b0..38783e9ee 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -111,16 +111,7 @@ class GitCommandManager { async branchList(remote: boolean): Promise { const result: string[] = [] - - // Note, this implementation uses "rev-parse --symbolic-full-name" because the output from - // "branch --list" is more difficult when in a detached HEAD state. - - // TODO(https://github.com/actions/checkout/issues/786): this implementation uses - // "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'] if (remote) { args.push('--remotes=origin') } else { From 425626d2593bd31950dcb4f04302749ac6f46e7b Mon Sep 17 00:00:00 2001 From: John Wesley Walker III <81404201+jww3@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:45:21 +0000 Subject: [PATCH 5/5] Bump `MinimumGitVersion` to 2.28 due to #1386 --- README.md | 2 +- __test__/git-command-manager.test.ts | 6 +++--- dist/index.js | 11 ++--------- package-lock.json | 4 ++-- package.json | 2 +- src/git-command-manager.ts | 14 +++----------- 6 files changed, 12 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 2858d4651..7ec08ce6e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Only a single commit is fetched by default, for the ref/SHA that triggered the w The auth token is persisted in the local git config. This enables your scripts to run authenticated git commands. The token is removed during post-job cleanup. Set `persist-credentials: false` to opt-out. -When Git 2.25 or higher is not in your PATH, falls back to the REST API to download the files. +When Git 2.28 or higher is not in your PATH, falls back to the REST API to download the files. # What's new diff --git a/__test__/git-command-manager.test.ts b/__test__/git-command-manager.test.ts index fcffe04e4..e7af4c94a 100644 --- a/__test__/git-command-manager.test.ts +++ b/__test__/git-command-manager.test.ts @@ -24,7 +24,7 @@ describe('git-auth-helper tests', () => { console.log(args, options.listeners.stdout) if (args.includes('version')) { - options.listeners.stdout(Buffer.from('2.25')) + options.listeners.stdout(Buffer.from('2.28')) return 0 } @@ -57,7 +57,7 @@ describe('git-auth-helper tests', () => { console.log(args, options.listeners.stdout) if (args.includes('version')) { - options.listeners.stdout(Buffer.from('2.25')) + options.listeners.stdout(Buffer.from('2.28')) return 0 } @@ -97,7 +97,7 @@ describe('Test fetchDepth and fetchTags options', () => { console.log(args, options.listeners.stdout) if (args.includes('version')) { - options.listeners.stdout(Buffer.from('2.25')) + options.listeners.stdout(Buffer.from('2.28')) } return 0 diff --git a/dist/index.js b/dist/index.js index 42e029761..72e40d806 100644 --- a/dist/index.js +++ b/dist/index.js @@ -480,8 +480,8 @@ const retryHelper = __importStar(__nccwpck_require__(2155)); const git_version_1 = __nccwpck_require__(3142); // Auth header not supported before 2.9 // Wire protocol v2 not supported before 2.18 -// sparse-checkout not supported before 2.25 -exports.MinimumGitVersion = new git_version_1.GitVersion('2.25'); +// sparse-checkout not [well-]supported before 2.28 (see https://github.com/actions/checkout/issues/1386) +exports.MinimumGitVersion = new git_version_1.GitVersion('2.28'); function createCommandManager(workingDirectory, lfs, doSparseCheckout) { return __awaiter(this, void 0, void 0, function* () { return yield GitCommandManager.createCommandManager(workingDirectory, lfs, doSparseCheckout); @@ -937,13 +937,6 @@ class GitCommandManager { } } this.doSparseCheckout = doSparseCheckout; - if (this.doSparseCheckout) { - // The `git sparse-checkout` command was introduced in Git v2.25.0 - const minimumGitSparseCheckoutVersion = new git_version_1.GitVersion('2.25'); - if (!gitVersion.checkMinimum(minimumGitSparseCheckoutVersion)) { - throw new Error(`Minimum Git version required for sparse checkout is ${minimumGitSparseCheckoutVersion}. Your git ('${this.gitPath}') is ${gitVersion}`); - } - } // Set the user agent const gitHttpUserAgent = `git/${gitVersion} (github-actions-checkout)`; core.debug(`Set git useragent to: ${gitHttpUserAgent}`); diff --git a/package-lock.json b/package-lock.json index 9834e50ee..ce0af4ecd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "checkout", - "version": "4.1.2", + "version": "5.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "checkout", - "version": "4.1.2", + "version": "5.0.0", "license": "MIT", "dependencies": { "@actions/core": "^1.10.0", diff --git a/package.json b/package.json index 651d6a02a..2febd44b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "checkout", - "version": "4.1.2", + "version": "5.0.0", "description": "checkout action", "main": "lib/main.js", "scripts": { diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index 38783e9ee..1ce9aa3d0 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -11,8 +11,8 @@ import {GitVersion} from './git-version' // Auth header not supported before 2.9 // Wire protocol v2 not supported before 2.18 -// sparse-checkout not supported before 2.25 -export const MinimumGitVersion = new GitVersion('2.25') +// sparse-checkout not [well-]supported before 2.28 (see https://github.com/actions/checkout/issues/1386) +export const MinimumGitVersion = new GitVersion('2.28') export interface IGitCommandManager { branchDelete(remote: boolean, branch: string): Promise @@ -597,15 +597,7 @@ class GitCommandManager { } this.doSparseCheckout = doSparseCheckout - if (this.doSparseCheckout) { - // The `git sparse-checkout` command was introduced in Git v2.25.0 - const minimumGitSparseCheckoutVersion = new GitVersion('2.25') - if (!gitVersion.checkMinimum(minimumGitSparseCheckoutVersion)) { - throw new Error( - `Minimum Git version required for sparse checkout is ${minimumGitSparseCheckoutVersion}. Your git ('${this.gitPath}') is ${gitVersion}` - ) - } - } + // Set the user agent const gitHttpUserAgent = `git/${gitVersion} (github-actions-checkout)` core.debug(`Set git useragent to: ${gitHttpUserAgent}`)