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 # Default: 1
fetch-depth: '' fetch-depth: ''
# Number of fetches to perform simultaneously when updating submodules. 0 # Number of fetches to perform simultaneously when updating submodules: -1
# indicates default (serial updates). # indicates to use git default (serial updates). 0 uses as many jobs as there are
# Default: 0 # processors.
# Default: -1
fetch-jobs: '' fetch-jobs: ''
# Whether to download Git-LFS files # Whether to download Git-LFS files

View File

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

View File

@ -75,7 +75,7 @@ describe('input-helper tests', () => {
expect(settings.commit).toBeTruthy() expect(settings.commit).toBeTruthy()
expect(settings.commit).toBe('1234567890123456789012345678901234567890') expect(settings.commit).toBe('1234567890123456789012345678901234567890')
expect(settings.fetchDepth).toBe(1) expect(settings.fetchDepth).toBe(1)
expect(settings.fetchJobs).toBe(0) expect(settings.fetchJobs).toBe(-1)
expect(settings.lfs).toBe(false) expect(settings.lfs).toBe(false)
expect(settings.ref).toBe('refs/heads/some-ref') expect(settings.ref).toBe('refs/heads/some-ref')
expect(settings.repositoryName).toBe('some-repo') 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.' description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
default: 1 default: 1
fetch-jobs: fetch-jobs:
description: 'Number of fetches to perform simultaneously when updating submodules. 0 indicates default (serial updates).' description: >
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
lfs: lfs:
description: 'Whether to download Git-LFS files' description: 'Whether to download Git-LFS files'
default: false default: false

8
dist/index.js vendored
View File

@ -5949,7 +5949,7 @@ class GitCommandManager {
if (recursive) { if (recursive) {
args.push('--recursive'); args.push('--recursive');
} }
if (fetchJobs > 0) { if (fetchJobs > -1) {
args.push(`--jobs=${fetchJobs}`); args.push(`--jobs=${fetchJobs}`);
} }
yield this.execGit(args); yield this.execGit(args);
@ -14571,9 +14571,9 @@ function getInputs() {
} }
core.debug(`fetch depth = ${result.fetchDepth}`); core.debug(`fetch depth = ${result.fetchDepth}`);
// Fetch jobs // Fetch jobs
result.fetchJobs = Math.floor(Number(core.getInput('fetch-jobs') || '0')); result.fetchJobs = Math.floor(Number(core.getInput('fetch-jobs') || '-1'));
if (isNaN(result.fetchJobs) || result.fetchJobs < 0) { if (isNaN(result.fetchJobs) || result.fetchJobs < -1) {
result.fetchJobs = 0; result.fetchJobs = -1;
} }
core.debug(`fetch jobs = ${result.fetchJobs}`); core.debug(`fetch jobs = ${result.fetchJobs}`);
// LFS // LFS

View File

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

View File

@ -89,9 +89,9 @@ export function getInputs(): IGitSourceSettings {
core.debug(`fetch depth = ${result.fetchDepth}`) core.debug(`fetch depth = ${result.fetchDepth}`)
// Fetch jobs // Fetch jobs
result.fetchJobs = Math.floor(Number(core.getInput('fetch-jobs') || '0')) result.fetchJobs = Math.floor(Number(core.getInput('fetch-jobs') || '-1'))
if (isNaN(result.fetchJobs) || result.fetchJobs < 0) { if (isNaN(result.fetchJobs) || result.fetchJobs < -1) {
result.fetchJobs = 0 result.fetchJobs = -1
} }
core.debug(`fetch jobs = ${result.fetchJobs}`) core.debug(`fetch jobs = ${result.fetchJobs}`)