3
0
Fork 0
mirror of https://code.forgejo.org/actions/checkout.git synced 2025-04-24 12:25:34 +00:00
This commit is contained in:
Nacho Orlandoni 2025-01-27 14:12:05 +00:00 committed by GitHub
commit 8c2f86ce2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 71 additions and 1 deletions

20
dist/index.js vendored
View file

@ -748,6 +748,13 @@ class GitCommandManager {
yield this.execGit(['remote', 'add', remoteName, remoteUrl]);
});
}
referenceAdd(alternateObjects) {
return __awaiter(this, void 0, void 0, function* () {
const alternatePath = path.join(this.workingDirectory, '.git/objects/info/alternates');
core.info(`Adding a git alternate to reference repo at ${alternateObjects}`);
yield fs.promises.writeFile(alternatePath, `${alternateObjects}\n`);
});
}
removeEnvironmentVariable(name) {
delete this.gitEnv[name];
}
@ -1239,6 +1246,17 @@ function getSource(settings) {
yield git.init();
yield git.remoteAdd('origin', repositoryUrl);
core.endGroup();
if (settings.reference !== undefined) {
const alternateObjects = path.join(settings.reference, '/objects');
if (fsHelper.directoryExistsSync(alternateObjects, false)) {
core.startGroup('Adding a reference repository');
yield git.referenceAdd(alternateObjects);
core.endGroup();
}
else {
core.warning(`Reference repository was specified, but directory ${alternateObjects} does not exists`);
}
}
}
// Disable automatic garbage collection
core.startGroup('Disabling automatic garbage collection');
@ -1831,6 +1849,8 @@ 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}`);
result.reference = core.getInput('reference');
core.debug(`Reference repository = ${result.reference}`);
return result;
});
}