Compare commits

..

1 Commits
main ... main

Author SHA1 Message Date
Elisei Roca
d8dc644b1c Add support for SHA256 repositories
New input parameter to specify the git object format when initializing a
git repository.
2025-04-05 11:29:03 +02:00
8 changed files with 23 additions and 26 deletions

View File

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

View File

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

View File

@@ -98,10 +98,9 @@ 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
repo-sha256:
description: 'Set Git object format to "sha256" when initializing a Git repository.'
object-format:
description: 'Specify the Git object format for repository initialization (sha1, sha256).'
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(repoSHA256) {
init(objectFormat) {
return __awaiter(this, void 0, void 0, function* () {
const args = ['init'];
if (repoSHA256) {
args.push(`--object-format=sha256`);
if (objectFormat) {
args.push(`--object-format=${objectFormat}`);
}
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.repoSHA256);
yield git.init(settings.objectFormat);
yield git.remoteAdd('origin', repositoryUrl);
core.endGroup();
}
@@ -1836,10 +1836,9 @@ 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}`);
// 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}`);
// Retrieve the Git object format for initializing a Git repository.
result.objectFormat = core.getInput('object-format');
core.debug(`git object format = ${result.objectFormat}`);
return result;
});
}

View File

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

View File

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

View File

@@ -161,10 +161,9 @@ 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}`)
// Retrieve the Git object format for initializing a Git repository.
result.objectFormat = core.getInput('object-format')
core.debug(`git object format = ${result.objectFormat}`)
return result
}