3
0
Fork 0
mirror of https://code.forgejo.org/actions/checkout.git synced 2025-04-24 12:25:34 +00:00

Reference support

* Add support for reference repository parameter

---------

Co-authored-by: Diego Dompe <ddompe@gmail.com>
This commit is contained in:
Nacho Orlandoni 2023-10-28 11:30:25 -04:00 committed by GitHub
parent b4ffde65f4
commit 65f77605c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 71 additions and 1 deletions

20
dist/index.js vendored
View file

@ -732,6 +732,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];
}
@ -1211,6 +1218,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');
@ -1790,6 +1808,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;
});
}