mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-24 12:25:34 +00:00
Add string[] option to submodules
Allows checking out only specific submodules instead of all
This commit is contained in:
parent
9a9194f871
commit
b6625bb44a
10 changed files with 128 additions and 22 deletions
44
dist/index.js
vendored
44
dist/index.js
vendored
|
@ -795,17 +795,32 @@ class GitCommandManager {
|
|||
yield this.execGit(args);
|
||||
});
|
||||
}
|
||||
submoduleUpdate(fetchDepth, recursive) {
|
||||
submoduleUpdate(fetchDepth, recursive, submoduleDirectories) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const args = ['-c', 'protocol.version=2'];
|
||||
args.push('submodule', 'update', '--init', '--force');
|
||||
if (fetchDepth > 0) {
|
||||
args.push(`--depth=${fetchDepth}`);
|
||||
if (submoduleDirectories) {
|
||||
for (const submodule of submoduleDirectories) {
|
||||
const args = ['-c', 'protocol.version=2'];
|
||||
args.push('submodule', 'update', '--init', '--force', submodule);
|
||||
if (fetchDepth > 0) {
|
||||
args.push(`--depth=${fetchDepth}`);
|
||||
}
|
||||
if (recursive) {
|
||||
args.push('--recursive');
|
||||
}
|
||||
yield this.execGit(args);
|
||||
}
|
||||
}
|
||||
if (recursive) {
|
||||
args.push('--recursive');
|
||||
else {
|
||||
const args = ['-c', 'protocol.version=2'];
|
||||
args.push('submodule', 'update', '--init', '--force');
|
||||
if (fetchDepth > 0) {
|
||||
args.push(`--depth=${fetchDepth}`);
|
||||
}
|
||||
if (recursive) {
|
||||
args.push('--recursive');
|
||||
}
|
||||
yield this.execGit(args);
|
||||
}
|
||||
yield this.execGit(args);
|
||||
});
|
||||
}
|
||||
submoduleStatus() {
|
||||
|
@ -1342,7 +1357,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.submoduleDirectories);
|
||||
yield git.submoduleForeach('git config --local gc.auto 0', settings.nestedSubmodules);
|
||||
core.endGroup();
|
||||
// Persist credentials
|
||||
|
@ -1805,6 +1820,7 @@ function getInputs() {
|
|||
// Submodules
|
||||
result.submodules = false;
|
||||
result.nestedSubmodules = false;
|
||||
result.submoduleDirectories = null;
|
||||
const submodulesString = (core.getInput('submodules') || '').toUpperCase();
|
||||
if (submodulesString == 'RECURSIVE') {
|
||||
result.submodules = true;
|
||||
|
@ -1813,8 +1829,18 @@ function getInputs() {
|
|||
else if (submodulesString == 'TRUE') {
|
||||
result.submodules = true;
|
||||
}
|
||||
const submoduleDirectories = core.getMultilineInput('submodule-directories');
|
||||
if (submoduleDirectories.length > 0) {
|
||||
result.submoduleDirectories = submoduleDirectories;
|
||||
if (!result.submodules)
|
||||
result.submodules = true;
|
||||
}
|
||||
else {
|
||||
result.submoduleDirectories = null;
|
||||
}
|
||||
core.debug(`submodules = ${result.submodules}`);
|
||||
core.debug(`recursive submodules = ${result.nestedSubmodules}`);
|
||||
core.debug(`submodule directories = ${result.submoduleDirectories}`);
|
||||
// Auth token
|
||||
result.authToken = core.getInput('token', { required: true });
|
||||
// SSH
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue