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

Add objectFormat setting to allow init()ing a repo with sha256 #1945

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Add objectFormat setting to allow init()ing a repo with sha256
  • Loading branch information
yangskyboxlabs committed Oct 15, 2024
commit 68a03db89927bb75b55c815d96b14d78e1846aa1
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -126,6 +126,11 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
# running from unless specified. Example URLs are https://github.com or
# https://my-ghes-server.example.com
github-server-url: ''

# Use the given object format when creating local repository. Specifically, use
# 'sha256' to checkout a SHA-256 repository.
# Defualt: null
object-format: ''
```
<!-- end usage -->

@@ -143,6 +148,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
- [Checkout pull request HEAD commit instead of merge commit](#Checkout-pull-request-HEAD-commit-instead-of-merge-commit)
- [Checkout pull request on closed event](#Checkout-pull-request-on-closed-event)
- [Push a commit using the built-in token](#Push-a-commit-using-the-built-in-token)
- [Checkout SHA-256 repository](#checkout-sha-256-repository)

## Fetch only the root files

@@ -288,6 +294,14 @@ jobs:
```
*NOTE:* The user email is `{user.id}+{user.login}@users.noreply.github.com`. See users API: https://api.github.com/users/github-actions%5Bbot%5D

## Checkout SHA-256 repository

```yaml
- uses: actions/checkout@v4
with:
object-format: sha256
```

# License

The scripts and documentation in this project are released under the [MIT License](LICENSE)
3 changes: 2 additions & 1 deletion __test__/git-auth-helper.test.ts
Original file line number Diff line number Diff line change
@@ -824,7 +824,8 @@ async function setup(testName: string): Promise<void> {
sshUser: '',
workflowOrganizationId: 123456,
setSafeDirectory: true,
githubServerUrl: githubServerUrl
githubServerUrl: githubServerUrl,
objectFormat: undefined
}
}

27 changes: 27 additions & 0 deletions __test__/git-command-manager.test.ts
Original file line number Diff line number Diff line change
@@ -375,4 +375,31 @@ describe('Test fetchDepth and fetchTags options', () => {
expect.any(Object)
)
})

it('should call execGit wiwth the correct arguments when sha256 is used', async () => {
jest.spyOn(exec, 'exec').mockImplementation(mockExec)

const workingDirectory = 'test'
const lfs = false
const doSparseCheckout = false
git = await commandManager.createCommandManager(
workingDirectory,
lfs,
doSparseCheckout
)

await git.init({objectFormat: 'sha256'})
// await git.init({objectFormat: undefined})
Copy link
Author

Choose a reason for hiding this comment

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

Suggested change
// await git.init({objectFormat: undefined})


expect(mockExec).toHaveBeenCalledWith(
expect.any(String),
[
'init',
'--object-format=sha256',
'test'
],
expect.any(Object)
)
})
})

Loading
Oops, something went wrong.