Support fetch-jobs: 0 to use as many jobs as there are processors

The default is now fetch-jobs: -1, which is the new value for
reverting to normal git behavior (provide no --jobs argument).
This commit is contained in:
Frits Talbot 2020-10-10 10:02:44 +02:00
parent ad5dc19390
commit a5c1ce924a
7 changed files with 19 additions and 15 deletions

View file

@ -93,9 +93,10 @@ Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous
# Default: 1
fetch-depth: ''
# Number of fetches to perform simultaneously when updating submodules. 0
# indicates default (serial updates).
# Default: 0
# 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

View file

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

View file

@ -75,7 +75,7 @@ describe('input-helper tests', () => {
expect(settings.commit).toBeTruthy()
expect(settings.commit).toBe('1234567890123456789012345678901234567890')
expect(settings.fetchDepth).toBe(1)
expect(settings.fetchJobs).toBe(0)
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

@ -57,8 +57,11 @@ inputs:
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. 0 indicates default (serial updates).'
default: 0
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

8
dist/index.js vendored
View file

@ -5949,7 +5949,7 @@ class GitCommandManager {
if (recursive) {
args.push('--recursive');
}
if (fetchJobs > 0) {
if (fetchJobs > -1) {
args.push(`--jobs=${fetchJobs}`);
}
yield this.execGit(args);
@ -14571,9 +14571,9 @@ function getInputs() {
}
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;
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}`);
// LFS

View file

@ -327,7 +327,7 @@ class GitCommandManager {
args.push('--recursive')
}
if (fetchJobs > 0) {
if (fetchJobs > -1) {
args.push(`--jobs=${fetchJobs}`)
}

View file

@ -89,9 +89,9 @@ 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
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}`)