Compare commits

..

1 Commits
v4 ... v4

Author SHA1 Message Date
Elisei Roca
8cfb93e4f2 Add support for SHA256 repositories
New input parameter 'repo-sha256' to set the Git object format
to "sha256" when initializing a Git repository.
2025-04-02 10:09:44 +02:00
8 changed files with 26 additions and 23 deletions

View File

@@ -127,8 +127,9 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
# https://my-ghes-server.example.com
github-server-url: ''
# Specify the Git object format for repository initialization (sha1, sha256).
object-format: ''
# Set Git object format to "sha256" when initializing a Git repository.
# Default: false
repo-sha256: ''
```
<!-- end usage -->

View File

@@ -824,8 +824,7 @@ async function setup(testName: string): Promise<void> {
sshUser: '',
workflowOrganizationId: 123456,
setSafeDirectory: true,
githubServerUrl: githubServerUrl,
objectFormat: undefined
githubServerUrl: githubServerUrl
}
}

View File

@@ -98,9 +98,10 @@ inputs:
github-server-url:
description: The base URL for the GitHub instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://github.com or https://my-ghes-server.example.com
required: false
object-format:
description: 'Specify the Git object format for repository initialization (sha1, sha256).'
repo-sha256:
description: 'Set Git object format to "sha256" when initializing a Git repository.'
required: false
default: false
outputs:
ref:
description: 'The branch, tag or SHA that was checked out'

15
dist/index.js vendored
View File

@@ -709,11 +709,11 @@ class GitCommandManager {
getWorkingDirectory() {
return this.workingDirectory;
}
init(objectFormat) {
init(repoSHA256) {
return __awaiter(this, void 0, void 0, function* () {
const args = ['init'];
if (objectFormat) {
args.push(`--object-format=${objectFormat}`);
if (repoSHA256) {
args.push(`--object-format=sha256`);
}
args.push(this.workingDirectory);
yield this.execGit(args);
@@ -1241,7 +1241,7 @@ function getSource(settings) {
// Initialize the repository
if (!fsHelper.directoryExistsSync(path.join(settings.repositoryPath, '.git'))) {
core.startGroup('Initializing the repository');
yield git.init(settings.objectFormat);
yield git.init(settings.repoSHA256);
yield git.remoteAdd('origin', repositoryUrl);
core.endGroup();
}
@@ -1836,9 +1836,10 @@ function getInputs() {
// Determine the GitHub URL that the repository is being hosted from
result.githubServerUrl = core.getInput('github-server-url');
core.debug(`GitHub Host URL = ${result.githubServerUrl}`);
// Retrieve the Git object format for initializing a Git repository.
result.objectFormat = core.getInput('object-format');
core.debug(`git object format = ${result.objectFormat}`);
// 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;
});
}

View File

@@ -42,7 +42,7 @@ export interface IGitCommandManager {
): Promise<void>
getDefaultBranch(repositoryUrl: string): Promise<string>
getWorkingDirectory(): string
init(objectFormat?: string): Promise<void>
init(repoSHA256?: boolean): Promise<void>
isDetached(): Promise<boolean>
lfsFetch(ref: string): Promise<void>
lfsInstall(): Promise<void>
@@ -327,10 +327,10 @@ class GitCommandManager {
return this.workingDirectory
}
async init(objectFormat?: string): Promise<void> {
async init(repoSHA256?: boolean): Promise<void> {
const args = ['init']
if (objectFormat) {
args.push(`--object-format=${objectFormat}`)
if (repoSHA256) {
args.push(`--object-format=sha256`)
}
args.push(this.workingDirectory)
await this.execGit(args)

View File

@@ -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(settings.objectFormat)
await git.init(settings.repoSHA256)
await git.remoteAdd('origin', repositoryUrl)
core.endGroup()
}

View File

@@ -120,7 +120,7 @@ export interface IGitSourceSettings {
githubServerUrl: string | undefined
/**
* Specify the Git object format for repository initialization (sha1, sha256).
* Set Git object format to "sha256" when initializing a Git repository
*/
objectFormat: string | undefined
repoSHA256: boolean
}

View File

@@ -161,9 +161,10 @@ export async function getInputs(): Promise<IGitSourceSettings> {
result.githubServerUrl = core.getInput('github-server-url')
core.debug(`GitHub Host URL = ${result.githubServerUrl}`)
// Retrieve the Git object format for initializing a Git repository.
result.objectFormat = core.getInput('object-format')
core.debug(`git object format = ${result.objectFormat}`)
// 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
}