1
0
Fork 0
mirror of https://github.com/actions/checkout.git synced 2025-04-23 08:26:37 +02:00

Add objectFormat setting to allow init()ing a repo with sha256

This commit is contained in:
Yang Zhao 2024-08-23 00:23:06 -07:00
parent 85e6279cec
commit b9de40a228
9 changed files with 81 additions and 8 deletions

18
dist/index.js vendored
View file

@ -709,9 +709,13 @@ class GitCommandManager {
getWorkingDirectory() {
return this.workingDirectory;
}
init() {
init(options) {
return __awaiter(this, void 0, void 0, function* () {
yield this.execGit(['init', this.workingDirectory]);
yield this.execGit([
'init',
...((options === null || options === void 0 ? void 0 : options.objectFormat) ? [`--object-format=${options.objectFormat}`] : []),
this.workingDirectory
]);
});
}
isDetached() {
@ -1236,7 +1240,7 @@ function getSource(settings) {
// Initialize the repository
if (!fsHelper.directoryExistsSync(path.join(settings.repositoryPath, '.git'))) {
core.startGroup('Initializing the repository');
yield git.init();
yield git.init({ objectFormat: settings.objectFormat });
yield git.remoteAdd('origin', repositoryUrl);
core.endGroup();
}
@ -1831,6 +1835,14 @@ 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}`);
// Object format
const objectFormat = core.getInput('object-format');
if (objectFormat) {
if (objectFormat != 'sha1' && objectFormat != 'sha256') {
throw Error(`Invalid object format '${objectFormat}'`);
}
result.objectFormat = objectFormat;
}
return result;
});
}