Add fetchJobs option to parallelize submodule updates

This commit is contained in:
Frits Talbot 2020-08-09 23:30:32 +02:00
parent 2036a08e25
commit ad5dc19390
9 changed files with 49 additions and 5 deletions

13
dist/index.js vendored
View file

@ -5939,7 +5939,7 @@ class GitCommandManager {
yield this.execGit(args);
});
}
submoduleUpdate(fetchDepth, recursive) {
submoduleUpdate(fetchDepth, recursive, fetchJobs) {
return __awaiter(this, void 0, void 0, function* () {
const args = ['-c', 'protocol.version=2'];
args.push('submodule', 'update', '--init', '--force');
@ -5949,6 +5949,9 @@ class GitCommandManager {
if (recursive) {
args.push('--recursive');
}
if (fetchJobs > 0) {
args.push(`--jobs=${fetchJobs}`);
}
yield this.execGit(args);
});
}
@ -6252,7 +6255,7 @@ function getSource(settings) {
// Checkout submodules
core.startGroup('Fetching submodules');
yield git.submoduleSync(settings.nestedSubmodules);
yield git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules);
yield git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules, settings.fetchJobs);
yield git.submoduleForeach('git config --local gc.auto 0', settings.nestedSubmodules);
core.endGroup();
// Persist credentials
@ -14567,6 +14570,12 @@ function getInputs() {
result.fetchDepth = 0;
}
core.debug(`fetch depth = ${result.fetchDepth}`);
// Fetch jobs
result.fetchJobs = Math.floor(Number(core.getInput('fetch-jobs') || '0'));
if (isNaN(result.fetchJobs) || result.fetchJobs < 0) {
result.fetchJobs = 0;
}
core.debug(`fetch jobs = ${result.fetchJobs}`);
// LFS
result.lfs = (core.getInput('lfs') || 'false').toUpperCase() === 'TRUE';
core.debug(`lfs = ${result.lfs}`);