Add sparse checkout support

This commit is contained in:
Jonne Laagland Winder 2022-01-31 23:14:53 +00:00
parent 230611dbd0
commit ad6eac3f6b
11 changed files with 128 additions and 0 deletions

27
dist/index.js vendored
View file

@ -7076,6 +7076,17 @@ class GitCommandManager {
return output.exitCode === 0;
});
}
sparseCheckout(cone, paths) {
return __awaiter(this, void 0, void 0, function* () {
const args1 = ['sparse-checkout', 'init'];
if (cone) {
args1.push('--cone');
}
const args2 = ['sparse-checkout', 'set', '--', ...paths];
yield this.execGit(args1);
yield this.execGit(args2);
});
}
submoduleForeach(command, recursive) {
return __awaiter(this, void 0, void 0, function* () {
const args = ['submodule', 'foreach'];
@ -7409,6 +7420,12 @@ function getSource(settings) {
yield git.lfsFetch(checkoutInfo.startPoint || checkoutInfo.ref);
core.endGroup();
}
// Sparse checkout
if (settings.sparse) {
core.startGroup('Sparse checkout');
yield git.sparseCheckout(settings.sparseCone, settings.sparse);
core.endGroup();
}
// Checkout
core.startGroup('Checking out the ref');
yield git.checkout(checkoutInfo.ref, checkoutInfo.startPoint);
@ -17219,6 +17236,16 @@ function getInputs() {
// LFS
result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE';
core.debug(`lfs = ${result.lfs}`);
if (core.getInput('sparse')) {
const paths = core
.getInput('sparse')
.trim()
.split(`\n`)
.map(s => s.trim());
result.sparse = paths;
}
result.sparseCone =
(core.getInput('sparse-cone') || 'false').toUpperCase() === 'TRUE';
// Submodules
result.submodules = false;
result.nestedSubmodules = false;