mirror of
https://github.com/actions/checkout.git
synced 2026-01-20 07:38:53 +08:00
Add support for SHA256 repositories
New input parameter 'repo-sha256' to set the Git object format to "sha256" when initializing a Git repository.
This commit is contained in:
parent
cbb722410c
commit
57e16d7d9f
7 changed files with 39 additions and 7 deletions
|
|
@ -42,7 +42,7 @@ export interface IGitCommandManager {
|
|||
): Promise<void>
|
||||
getDefaultBranch(repositoryUrl: string): Promise<string>
|
||||
getWorkingDirectory(): string
|
||||
init(): Promise<void>
|
||||
init(repoSHA256?: boolean): Promise<void>
|
||||
isDetached(): Promise<boolean>
|
||||
lfsFetch(ref: string): Promise<void>
|
||||
lfsInstall(): Promise<void>
|
||||
|
|
@ -327,8 +327,13 @@ class GitCommandManager {
|
|||
return this.workingDirectory
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
await this.execGit(['init', this.workingDirectory])
|
||||
async init(repoSHA256?: boolean): Promise<void> {
|
||||
const args = ['init']
|
||||
if (repoSHA256) {
|
||||
args.push(`--object-format=sha256`)
|
||||
}
|
||||
args.push(this.workingDirectory)
|
||||
await this.execGit(args)
|
||||
}
|
||||
|
||||
async isDetached(): Promise<boolean> {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
!fsHelper.directoryExistsSync(path.join(settings.repositoryPath, '.git'))
|
||||
) {
|
||||
core.startGroup('Initializing the repository')
|
||||
await git.init()
|
||||
await git.init(settings.repoSHA256)
|
||||
await git.remoteAdd('origin', repositoryUrl)
|
||||
core.endGroup()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,4 +118,9 @@ export interface IGitSourceSettings {
|
|||
* User override on the GitHub Server/Host URL that hosts the repository to be cloned
|
||||
*/
|
||||
githubServerUrl: string | undefined
|
||||
|
||||
/**
|
||||
* Set Git object format to "sha256" when initializing a Git repository
|
||||
*/
|
||||
repoSHA256: boolean
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,5 +161,10 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||
result.githubServerUrl = core.getInput('github-server-url')
|
||||
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
|
||||
|
||||
// Set Git object format to "sha256" when initializing a Git repository.
|
||||
result.repoSHA256 =
|
||||
(core.getInput('repo-sha256') || 'false').toUpperCase() === 'TRUE'
|
||||
core.debug(`Repo object format sha256 = ${result.repoSHA256}`)
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue