mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-21 17:12:03 +03:00
Add fetchJobs option to parallelize submodule updates
This commit is contained in:
parent
2036a08e25
commit
ad5dc19390
9 changed files with 49 additions and 5 deletions
|
@ -39,7 +39,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>
|
||||
|
@ -308,7 +312,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) {
|
||||
|
@ -319,6 +327,10 @@ class GitCommandManager {
|
|||
args.push('--recursive')
|
||||
}
|
||||
|
||||
if (fetchJobs > 0) {
|
||||
args.push(`--jobs=${fetchJobs}`)
|
||||
}
|
||||
|
||||
await this.execGit(args)
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,8 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
await git.submoduleSync(settings.nestedSubmodules)
|
||||
await git.submoduleUpdate(
|
||||
settings.fetchDepth,
|
||||
settings.nestedSubmodules
|
||||
settings.nestedSubmodules,
|
||||
settings.fetchJobs
|
||||
)
|
||||
await git.submoduleForeach(
|
||||
'git config --local gc.auto 0',
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -88,6 +88,13 @@ export function getInputs(): IGitSourceSettings {
|
|||
}
|
||||
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}`)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue