Skip to content

Commit 68a03db

Browse files
committedOct 15, 2024
Add objectFormat setting to allow init()ing a repo with sha256
1 parent eef6144 commit 68a03db

8 files changed

+120
-39
lines changed
 

‎README.md

+14
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
126126
# running from unless specified. Example URLs are https://github.com or
127127
# https://my-ghes-server.example.com
128128
github-server-url: ''
129+
130+
# Use the given object format when creating local repository. Specifically, use
131+
# 'sha256' to checkout a SHA-256 repository.
132+
# Defualt: null
133+
object-format: ''
129134
```
130135
<!-- end usage -->
131136
@@ -143,6 +148,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
143148
- [Checkout pull request HEAD commit instead of merge commit](#Checkout-pull-request-HEAD-commit-instead-of-merge-commit)
144149
- [Checkout pull request on closed event](#Checkout-pull-request-on-closed-event)
145150
- [Push a commit using the built-in token](#Push-a-commit-using-the-built-in-token)
151+
- [Checkout SHA-256 repository](#checkout-sha-256-repository)
146152

147153
## Fetch only the root files
148154

@@ -288,6 +294,14 @@ jobs:
288294
```
289295
*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
290296

297+
## Checkout SHA-256 repository
298+
299+
```yaml
300+
- uses: actions/checkout@v4
301+
with:
302+
object-format: sha256
303+
```
304+
291305
# License
292306

293307
The scripts and documentation in this project are released under the [MIT License](LICENSE)

‎__test__/git-auth-helper.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,8 @@ async function setup(testName: string): Promise<void> {
824824
sshUser: '',
825825
workflowOrganizationId: 123456,
826826
setSafeDirectory: true,
827-
githubServerUrl: githubServerUrl
827+
githubServerUrl: githubServerUrl,
828+
objectFormat: undefined
828829
}
829830
}
830831

‎__test__/git-command-manager.test.ts

+27
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,31 @@ describe('Test fetchDepth and fetchTags options', () => {
375375
expect.any(Object)
376376
)
377377
})
378+
379+
it('should call execGit wiwth the correct arguments when sha256 is used', async () => {
380+
jest.spyOn(exec, 'exec').mockImplementation(mockExec)
381+
382+
const workingDirectory = 'test'
383+
const lfs = false
384+
const doSparseCheckout = false
385+
git = await commandManager.createCommandManager(
386+
workingDirectory,
387+
lfs,
388+
doSparseCheckout
389+
)
390+
391+
await git.init({objectFormat: 'sha256'})
392+
// await git.init({objectFormat: undefined})
393+
394+
expect(mockExec).toHaveBeenCalledWith(
395+
expect.any(String),
396+
[
397+
'init',
398+
'--object-format=sha256',
399+
'test'
400+
],
401+
expect.any(Object)
402+
)
403+
})
378404
})
405+

0 commit comments

Comments
 (0)
Failed to load comments.