Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In consideration of a future v5, update minimum git version. #1653

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.28 or higher is not in your PATH, falls back to the REST API to download the files.

# What's new

Expand Down
6 changes: 3 additions & 3 deletions __test__/git-command-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.28'))
return 0
}

Expand Down Expand Up @@ -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.28'))
return 0
}

Expand Down Expand Up @@ -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.28'))
}

return 0
Expand Down
18 changes: 3 additions & 15 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [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);
Expand Down Expand Up @@ -523,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');
}
Expand Down Expand Up @@ -942,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}`);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "checkout",
"version": "4.1.2",
"version": "5.0.0",
"description": "checkout action",
"main": "lib/main.js",
"scripts": {
Expand Down
24 changes: 4 additions & 20 deletions src/git-command-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [well-]supported before 2.28 (see https://github.com/actions/checkout/issues/1386)
export const MinimumGitVersion = new GitVersion('2.28')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider an even higher version in light of #1708.

2.34.1 exhibits the problem reported in #1708.
2.43.0 works, but there's probably an earlier candidate that would also work.

(Need to go through the git release notes between version range [2.34 - 2.43] and find where they addressed compatibility issues associated with repositoryformatversion=1)


export interface IGitCommandManager {
branchDelete(remote: boolean, branch: string): Promise<void>
Expand Down Expand Up @@ -110,16 +111,7 @@ class GitCommandManager {

async branchList(remote: boolean): Promise<string[]> {
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']
Comment on lines -114 to -122
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: confirm this git rev-parse bug is fixed in git version 2.28+.

const args = ['rev-parse', '--symbolic']
if (remote) {
args.push('--remotes=origin')
} else {
Expand Down Expand Up @@ -605,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}`)
Expand Down
Loading