8 files changed +120
-39
lines changed 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/
126
126
# running from unless specified. Example URLs are https://github.com or
127
127
# https://my-ghes-server.example.com
128
128
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 : ' '
129
134
` ` `
130
135
<!-- end usage -->
131
136
@@ -143,6 +148,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
143
148
- [Checkout pull request HEAD commit instead of merge commit](#Checkout-pull-request-HEAD-commit-instead-of-merge-commit)
144
149
- [Checkout pull request on closed event](#Checkout-pull-request-on-closed-event)
145
150
- [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)
146
152
147
153
# # Fetch only the root files
148
154
@@ -288,6 +294,14 @@ jobs:
288
294
` ` `
289
295
*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
290
296
297
+ # # Checkout SHA-256 repository
298
+
299
+ ` ` ` yaml
300
+ - uses: actions/checkout@v4
301
+ with:
302
+ object-format: sha256
303
+ ` ` `
304
+
291
305
# License
292
306
293
307
The scripts and documentation in this project are released under the [MIT License](LICENSE)
Original file line number Diff line number Diff line change @@ -824,7 +824,8 @@ async function setup(testName: string): Promise<void> {
824
824
sshUser : '' ,
825
825
workflowOrganizationId : 123456 ,
826
826
setSafeDirectory : true ,
827
- githubServerUrl : githubServerUrl
827
+ githubServerUrl : githubServerUrl ,
828
+ objectFormat : undefined
828
829
}
829
830
}
830
831
Original file line number Diff line number Diff line change @@ -375,4 +375,31 @@ describe('Test fetchDepth and fetchTags options', () => {
375
375
expect . any ( Object )
376
376
)
377
377
} )
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
+ } )
378
404
} )
405
+
0 commit comments