1
0
Fork 0
mirror of https://github.com/actions/checkout.git synced 2025-03-31 05:20:06 +02:00
This commit is contained in:
Frits Talbot 2022-12-31 10:59:09 +00:00 committed by GitHub
commit 31d73c4b7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 5 deletions

View file

@ -78,6 +78,12 @@ When Git 2.18 or higher is not in your PATH, falls back to the REST API to downl
# Default: 1
fetch-depth: ''
# Number of fetches to perform simultaneously when updating submodules: -1
# indicates to use git default (serial updates). 0 uses as many jobs as there are
# processors.
# Default: -1
fetch-jobs: ''
# Whether to download Git-LFS files
# Default: false
lfs: ''

View file

@ -798,6 +798,7 @@ async function setup(testName: string): Promise<void> {
clean: true,
commit: '',
fetchDepth: 1,
fetchJobs: -1,
lfs: false,
submodules: false,
nestedSubmodules: false,

View file

@ -80,6 +80,7 @@ describe('input-helper tests', () => {
expect(settings.commit).toBeTruthy()
expect(settings.commit).toBe('1234567890123456789012345678901234567890')
expect(settings.fetchDepth).toBe(1)
expect(settings.fetchJobs).toBe(-1)
expect(settings.lfs).toBe(false)
expect(settings.ref).toBe('refs/heads/some-ref')
expect(settings.repositoryName).toBe('some-repo')

View file

@ -56,6 +56,12 @@ inputs:
fetch-depth:
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
default: 1
fetch-jobs:
description: >
Number of fetches to perform simultaneously when updating submodules:
-1 indicates to use git default (serial updates). 0 uses as many jobs as
there are processors.
default: -1
lfs:
description: 'Whether to download Git-LFS files'
default: false

16
dist/index.js vendored
View file

@ -7670,7 +7670,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');
@ -7680,6 +7680,9 @@ class GitCommandManager {
if (recursive) {
args.push('--recursive');
}
if (fetchJobs > -1) {
args.push(`--jobs=${fetchJobs}`);
}
yield this.execGit(args);
});
}
@ -18537,6 +18540,15 @@ function getInputs() {
}
core.debug(`submodules = ${result.submodules}`);
core.debug(`recursive submodules = ${result.nestedSubmodules}`);
// Fetch jobs during submodule update
result.fetchJobs = -1;
if (result.submodules) {
result.fetchJobs = Math.floor(Number(core.getInput('fetch-jobs') || '-1'));
if (isNaN(result.fetchJobs) || result.fetchJobs < -1) {
result.fetchJobs = -1;
}
core.debug(`fetch jobs = ${result.fetchJobs}`);
}
// Auth token
result.authToken = core.getInput('token', { required: true });
// SSH
@ -32009,7 +32021,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

View file

@ -40,7 +40,11 @@ export interface IGitCommandManager {
shaExists(sha: string): Promise<boolean>
submoduleForeach(command: string, recursive: boolean): Promise<string>
submoduleSync(recursive: boolean): Promise<void>
submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void>
submoduleUpdate(
fetchDepth: number,
recursive: boolean,
fetchJobs: number
): Promise<void>
tagExists(pattern: string): Promise<boolean>
tryClean(): Promise<boolean>
tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
@ -343,7 +347,11 @@ class GitCommandManager {
await this.execGit(args)
}
async submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void> {
async submoduleUpdate(
fetchDepth: number,
recursive: boolean,
fetchJobs: number
): Promise<void> {
const args = ['-c', 'protocol.version=2']
args.push('submodule', 'update', '--init', '--force')
if (fetchDepth > 0) {
@ -354,6 +362,10 @@ class GitCommandManager {
args.push('--recursive')
}
if (fetchJobs > -1) {
args.push(`--jobs=${fetchJobs}`)
}
await this.execGit(args)
}

View file

@ -206,7 +206,11 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
// Checkout submodules
core.startGroup('Fetching submodules')
await git.submoduleSync(settings.nestedSubmodules)
await git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules)
await git.submoduleUpdate(
settings.fetchDepth,
settings.nestedSubmodules,
settings.fetchJobs
)
await git.submoduleForeach(
'git config --local gc.auto 0',
settings.nestedSubmodules

View file

@ -34,6 +34,11 @@ export interface IGitSourceSettings {
*/
fetchDepth: number
/**
* The number of fetches to perform simultaneously when updating submodules
*/
fetchJobs: number
/**
* Indicates whether to fetch LFS objects
*/

View file

@ -106,6 +106,16 @@ export async function getInputs(): Promise<IGitSourceSettings> {
core.debug(`submodules = ${result.submodules}`)
core.debug(`recursive submodules = ${result.nestedSubmodules}`)
// Fetch jobs during submodule update
result.fetchJobs = -1
if (result.submodules) {
result.fetchJobs = Math.floor(Number(core.getInput('fetch-jobs') || '-1'))
if (isNaN(result.fetchJobs) || result.fetchJobs < -1) {
result.fetchJobs = -1
}
core.debug(`fetch jobs = ${result.fetchJobs}`)
}
// Auth token
result.authToken = core.getInput('token', {required: true})