Enable sparse index to fix Git LFS performance with sparse checkouts

This commit is contained in:
Alexander Vostres 2026-03-17 22:15:29 +02:00
parent 0c366fd6a8
commit 23441d43ee
3 changed files with 13 additions and 3 deletions

8
dist/index.js vendored
View file

@ -645,7 +645,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MinimumGitSparseCheckoutVersion = exports.MinimumGitVersion = void 0;
exports.MinimumGitSparseIndexVersion = exports.MinimumGitSparseCheckoutVersion = exports.MinimumGitVersion = void 0;
exports.createCommandManager = createCommandManager;
const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
@ -661,6 +661,7 @@ const git_version_1 = __nccwpck_require__(3142);
// sparse-checkout not [well-]supported before 2.28 (see https://github.com/actions/checkout/issues/1386)
exports.MinimumGitVersion = new git_version_1.GitVersion('2.18');
exports.MinimumGitSparseCheckoutVersion = new git_version_1.GitVersion('2.28');
exports.MinimumGitSparseIndexVersion = new git_version_1.GitVersion('2.32');
function createCommandManager(workingDirectory, lfs, doSparseCheckout) {
return __awaiter(this, void 0, void 0, function* () {
return yield GitCommandManager.createCommandManager(workingDirectory, lfs, doSparseCheckout);
@ -1573,9 +1574,9 @@ function getSource(settings) {
yield git.lfsFetch(checkoutInfo.startPoint || checkoutInfo.ref);
core.endGroup();
}
let gitVersion = yield git.version();
// Sparse checkout
if (!settings.sparseCheckout) {
let gitVersion = yield git.version();
// no need to disable sparse-checkout if the installed git runtime doesn't even support it.
if (gitVersion.checkMinimum(git_command_manager_1.MinimumGitSparseCheckoutVersion)) {
yield git.disableSparseCheckout();
@ -1589,6 +1590,9 @@ function getSource(settings) {
else {
yield git.sparseCheckoutNonConeMode(settings.sparseCheckout);
}
if (gitVersion.checkMinimum(git_command_manager_1.MinimumGitSparseIndexVersion)) {
yield git.config('index.sparse', 'true', false);
}
core.endGroup();
}
// Checkout