feat: add matrix alias to simplify using outputs for matrix jobs (#1975)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
fe6c3ea0ca
commit
008ba8ceec
3
.github/workflows/matrix-example.yml
vendored
3
.github/workflows/matrix-example.yml
vendored
@ -24,8 +24,7 @@ jobs:
|
||||
id: changed-files
|
||||
uses: ./
|
||||
with:
|
||||
json: true
|
||||
escape_json: false
|
||||
matrix: true
|
||||
- name: List all changed files
|
||||
run: echo '${{ steps.changed-files.outputs.all_changed_files }}'
|
||||
|
||||
|
@ -219,6 +219,10 @@ inputs:
|
||||
description: "Apply the negation patterns first. NOTE: This affects how changed files are matched."
|
||||
required: false
|
||||
default: "false"
|
||||
matrix:
|
||||
description: "Output changed files in a format that can be used for matrix jobs. Alias for setting inputs `json` to `true` and `escape_json` to `false`."
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
outputs:
|
||||
added_files:
|
||||
|
11
dist/index.js
generated
vendored
11
dist/index.js
generated
vendored
@ -1540,8 +1540,13 @@ const getInputs = () => {
|
||||
required: false,
|
||||
trimWhitespace: false
|
||||
});
|
||||
const json = core.getBooleanInput('json', { required: false });
|
||||
const escapeJson = core.getBooleanInput('escape_json', { required: false });
|
||||
let json = core.getBooleanInput('json', { required: false });
|
||||
let escapeJson = core.getBooleanInput('escape_json', { required: false });
|
||||
const matrix = core.getBooleanInput('matrix', { required: false });
|
||||
if (matrix) {
|
||||
json = true;
|
||||
escapeJson = false;
|
||||
}
|
||||
const safeOutput = core.getBooleanInput('safe_output', { required: false });
|
||||
const fetchDepth = core.getInput('fetch_depth', { required: false });
|
||||
const sinceLastRemoteCommit = core.getBooleanInput('since_last_remote_commit', { required: false });
|
||||
@ -2457,7 +2462,7 @@ const isInsideWorkTree = (_0) => __awaiter(void 0, [_0], void 0, function* ({ cw
|
||||
silent: !core.isDebug()
|
||||
});
|
||||
if (stdout.trim() !== 'true') {
|
||||
core.debug(`The current working directory is not inside a git repository: ${cwd}`);
|
||||
core.warning(`The current working directory is not inside a git repository: ${cwd}`);
|
||||
}
|
||||
return stdout.trim() === 'true';
|
||||
});
|
||||
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
343
src/__tests__/__snapshots__/inputs.test.ts.snap
Normal file
343
src/__tests__/__snapshots__/inputs.test.ts.snap
Normal file
@ -0,0 +1,343 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`getInputs should correctly parse boolean inputs 1`] = `
|
||||
{
|
||||
"apiUrl": undefined,
|
||||
"baseSha": undefined,
|
||||
"diffRelative": "false",
|
||||
"dirNames": "false",
|
||||
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": "false",
|
||||
"dirNamesExcludeCurrentDir": "false",
|
||||
"dirNamesIncludeFiles": undefined,
|
||||
"dirNamesIncludeFilesSeparator": undefined,
|
||||
"escapeJson": false,
|
||||
"failOnInitialDiffError": "false",
|
||||
"failOnSubmoduleDiffError": "false",
|
||||
"fetchAdditionalSubmoduleHistory": "false",
|
||||
"files": undefined,
|
||||
"filesFromSourceFile": undefined,
|
||||
"filesFromSourceFileSeparator": undefined,
|
||||
"filesIgnore": undefined,
|
||||
"filesIgnoreFromSourceFile": undefined,
|
||||
"filesIgnoreFromSourceFileSeparator": undefined,
|
||||
"filesIgnoreSeparator": undefined,
|
||||
"filesIgnoreYaml": undefined,
|
||||
"filesIgnoreYamlFromSourceFile": undefined,
|
||||
"filesIgnoreYamlFromSourceFileSeparator": undefined,
|
||||
"filesSeparator": undefined,
|
||||
"filesYaml": undefined,
|
||||
"filesYamlFromSourceFile": undefined,
|
||||
"filesYamlFromSourceFileSeparator": undefined,
|
||||
"includeAllOldNewRenamedFiles": "false",
|
||||
"json": true,
|
||||
"negationPatternsFirst": "false",
|
||||
"oldNewFilesSeparator": undefined,
|
||||
"oldNewSeparator": undefined,
|
||||
"outputDir": undefined,
|
||||
"outputRenamedFilesAsDeletedAndAdded": "false",
|
||||
"path": undefined,
|
||||
"quotepath": "false",
|
||||
"recoverDeletedFiles": "false",
|
||||
"recoverDeletedFilesToDestination": undefined,
|
||||
"recoverFiles": undefined,
|
||||
"recoverFilesIgnore": undefined,
|
||||
"recoverFilesIgnoreSeparator": undefined,
|
||||
"recoverFilesSeparator": undefined,
|
||||
"safeOutput": "false",
|
||||
"separator": undefined,
|
||||
"sha": undefined,
|
||||
"since": undefined,
|
||||
"sinceLastRemoteCommit": "false",
|
||||
"skipInitialFetch": "true",
|
||||
"token": undefined,
|
||||
"until": undefined,
|
||||
"useRestApi": "false",
|
||||
"writeOutputFiles": "false",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`getInputs should correctly parse numeric inputs 1`] = `
|
||||
{
|
||||
"apiUrl": "",
|
||||
"baseSha": "",
|
||||
"diffRelative": true,
|
||||
"dirNames": false,
|
||||
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": false,
|
||||
"dirNamesExcludeCurrentDir": false,
|
||||
"dirNamesIncludeFiles": "",
|
||||
"dirNamesIncludeFilesSeparator": "",
|
||||
"dirNamesMaxDepth": 2,
|
||||
"escapeJson": false,
|
||||
"failOnInitialDiffError": false,
|
||||
"failOnSubmoduleDiffError": false,
|
||||
"fetchAdditionalSubmoduleHistory": false,
|
||||
"fetchDepth": 5,
|
||||
"files": "",
|
||||
"filesFromSourceFile": "",
|
||||
"filesFromSourceFileSeparator": "",
|
||||
"filesIgnore": "",
|
||||
"filesIgnoreFromSourceFile": "",
|
||||
"filesIgnoreFromSourceFileSeparator": "",
|
||||
"filesIgnoreSeparator": "",
|
||||
"filesIgnoreYaml": "",
|
||||
"filesIgnoreYamlFromSourceFile": "",
|
||||
"filesIgnoreYamlFromSourceFileSeparator": "",
|
||||
"filesSeparator": "",
|
||||
"filesYaml": "",
|
||||
"filesYamlFromSourceFile": "",
|
||||
"filesYamlFromSourceFileSeparator": "",
|
||||
"includeAllOldNewRenamedFiles": false,
|
||||
"json": false,
|
||||
"negationPatternsFirst": false,
|
||||
"oldNewFilesSeparator": "",
|
||||
"oldNewSeparator": "",
|
||||
"outputDir": "",
|
||||
"outputRenamedFilesAsDeletedAndAdded": false,
|
||||
"path": "",
|
||||
"quotepath": true,
|
||||
"recoverDeletedFiles": false,
|
||||
"recoverDeletedFilesToDestination": "",
|
||||
"recoverFiles": "",
|
||||
"recoverFilesIgnore": "",
|
||||
"recoverFilesIgnoreSeparator": "",
|
||||
"recoverFilesSeparator": "",
|
||||
"safeOutput": false,
|
||||
"separator": "",
|
||||
"sha": "",
|
||||
"since": "",
|
||||
"sinceLastRemoteCommit": false,
|
||||
"skipInitialFetch": false,
|
||||
"token": "",
|
||||
"until": "",
|
||||
"useRestApi": false,
|
||||
"writeOutputFiles": false,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`getInputs should correctly parse string inputs 1`] = `
|
||||
{
|
||||
"apiUrl": "https://api.github.com",
|
||||
"baseSha": "",
|
||||
"diffRelative": true,
|
||||
"dirNames": false,
|
||||
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": false,
|
||||
"dirNamesExcludeCurrentDir": false,
|
||||
"dirNamesIncludeFiles": "",
|
||||
"dirNamesIncludeFilesSeparator": "",
|
||||
"escapeJson": false,
|
||||
"failOnInitialDiffError": false,
|
||||
"failOnSubmoduleDiffError": false,
|
||||
"fetchAdditionalSubmoduleHistory": false,
|
||||
"files": "",
|
||||
"filesFromSourceFile": "",
|
||||
"filesFromSourceFileSeparator": "",
|
||||
"filesIgnore": "",
|
||||
"filesIgnoreFromSourceFile": "",
|
||||
"filesIgnoreFromSourceFileSeparator": "",
|
||||
"filesIgnoreSeparator": "",
|
||||
"filesIgnoreYaml": "",
|
||||
"filesIgnoreYamlFromSourceFile": "",
|
||||
"filesIgnoreYamlFromSourceFileSeparator": "",
|
||||
"filesSeparator": "",
|
||||
"filesYaml": "",
|
||||
"filesYamlFromSourceFile": "",
|
||||
"filesYamlFromSourceFileSeparator": "",
|
||||
"includeAllOldNewRenamedFiles": false,
|
||||
"json": false,
|
||||
"negationPatternsFirst": false,
|
||||
"oldNewFilesSeparator": "",
|
||||
"oldNewSeparator": "",
|
||||
"outputDir": "",
|
||||
"outputRenamedFilesAsDeletedAndAdded": false,
|
||||
"path": "",
|
||||
"quotepath": true,
|
||||
"recoverDeletedFiles": false,
|
||||
"recoverDeletedFilesToDestination": "",
|
||||
"recoverFiles": "",
|
||||
"recoverFilesIgnore": "",
|
||||
"recoverFilesIgnoreSeparator": "",
|
||||
"recoverFilesSeparator": "",
|
||||
"safeOutput": false,
|
||||
"separator": "",
|
||||
"sha": "",
|
||||
"since": "",
|
||||
"sinceLastRemoteCommit": false,
|
||||
"skipInitialFetch": false,
|
||||
"token": "token",
|
||||
"until": "",
|
||||
"useRestApi": false,
|
||||
"writeOutputFiles": false,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`getInputs should handle invalid numeric inputs correctly 1`] = `
|
||||
{
|
||||
"apiUrl": "",
|
||||
"baseSha": "",
|
||||
"diffRelative": true,
|
||||
"dirNames": false,
|
||||
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": false,
|
||||
"dirNamesExcludeCurrentDir": false,
|
||||
"dirNamesIncludeFiles": "",
|
||||
"dirNamesIncludeFilesSeparator": "",
|
||||
"dirNamesMaxDepth": 2,
|
||||
"escapeJson": false,
|
||||
"failOnInitialDiffError": false,
|
||||
"failOnSubmoduleDiffError": false,
|
||||
"fetchAdditionalSubmoduleHistory": false,
|
||||
"fetchDepth": NaN,
|
||||
"files": "",
|
||||
"filesFromSourceFile": "",
|
||||
"filesFromSourceFileSeparator": "",
|
||||
"filesIgnore": "",
|
||||
"filesIgnoreFromSourceFile": "",
|
||||
"filesIgnoreFromSourceFileSeparator": "",
|
||||
"filesIgnoreSeparator": "",
|
||||
"filesIgnoreYaml": "",
|
||||
"filesIgnoreYamlFromSourceFile": "",
|
||||
"filesIgnoreYamlFromSourceFileSeparator": "",
|
||||
"filesSeparator": "",
|
||||
"filesYaml": "",
|
||||
"filesYamlFromSourceFile": "",
|
||||
"filesYamlFromSourceFileSeparator": "",
|
||||
"includeAllOldNewRenamedFiles": false,
|
||||
"json": false,
|
||||
"negationPatternsFirst": false,
|
||||
"oldNewFilesSeparator": "",
|
||||
"oldNewSeparator": "",
|
||||
"outputDir": "",
|
||||
"outputRenamedFilesAsDeletedAndAdded": false,
|
||||
"path": "",
|
||||
"quotepath": true,
|
||||
"recoverDeletedFiles": false,
|
||||
"recoverDeletedFilesToDestination": "",
|
||||
"recoverFiles": "",
|
||||
"recoverFilesIgnore": "",
|
||||
"recoverFilesIgnoreSeparator": "",
|
||||
"recoverFilesSeparator": "",
|
||||
"safeOutput": false,
|
||||
"separator": "",
|
||||
"sha": "",
|
||||
"since": "",
|
||||
"sinceLastRemoteCommit": false,
|
||||
"skipInitialFetch": false,
|
||||
"token": "",
|
||||
"until": "",
|
||||
"useRestApi": false,
|
||||
"writeOutputFiles": false,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`getInputs should handle negative numeric inputs correctly 1`] = `
|
||||
{
|
||||
"apiUrl": "",
|
||||
"baseSha": "",
|
||||
"diffRelative": true,
|
||||
"dirNames": false,
|
||||
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": false,
|
||||
"dirNamesExcludeCurrentDir": false,
|
||||
"dirNamesIncludeFiles": "",
|
||||
"dirNamesIncludeFilesSeparator": "",
|
||||
"dirNamesMaxDepth": -2,
|
||||
"escapeJson": false,
|
||||
"failOnInitialDiffError": false,
|
||||
"failOnSubmoduleDiffError": false,
|
||||
"fetchAdditionalSubmoduleHistory": false,
|
||||
"fetchDepth": 2,
|
||||
"files": "",
|
||||
"filesFromSourceFile": "",
|
||||
"filesFromSourceFileSeparator": "",
|
||||
"filesIgnore": "",
|
||||
"filesIgnoreFromSourceFile": "",
|
||||
"filesIgnoreFromSourceFileSeparator": "",
|
||||
"filesIgnoreSeparator": "",
|
||||
"filesIgnoreYaml": "",
|
||||
"filesIgnoreYamlFromSourceFile": "",
|
||||
"filesIgnoreYamlFromSourceFileSeparator": "",
|
||||
"filesSeparator": "",
|
||||
"filesYaml": "",
|
||||
"filesYamlFromSourceFile": "",
|
||||
"filesYamlFromSourceFileSeparator": "",
|
||||
"includeAllOldNewRenamedFiles": false,
|
||||
"json": false,
|
||||
"negationPatternsFirst": false,
|
||||
"oldNewFilesSeparator": "",
|
||||
"oldNewSeparator": "",
|
||||
"outputDir": "",
|
||||
"outputRenamedFilesAsDeletedAndAdded": false,
|
||||
"path": "",
|
||||
"quotepath": true,
|
||||
"recoverDeletedFiles": false,
|
||||
"recoverDeletedFilesToDestination": "",
|
||||
"recoverFiles": "",
|
||||
"recoverFilesIgnore": "",
|
||||
"recoverFilesIgnoreSeparator": "",
|
||||
"recoverFilesSeparator": "",
|
||||
"safeOutput": false,
|
||||
"separator": "",
|
||||
"sha": "",
|
||||
"since": "",
|
||||
"sinceLastRemoteCommit": false,
|
||||
"skipInitialFetch": false,
|
||||
"token": "",
|
||||
"until": "",
|
||||
"useRestApi": false,
|
||||
"writeOutputFiles": false,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`getInputs should return default values when no inputs are provided 1`] = `
|
||||
{
|
||||
"apiUrl": undefined,
|
||||
"baseSha": undefined,
|
||||
"diffRelative": true,
|
||||
"dirNames": false,
|
||||
"dirNamesDeletedFilesIncludeOnlyDeletedDirs": false,
|
||||
"dirNamesExcludeCurrentDir": false,
|
||||
"dirNamesIncludeFiles": undefined,
|
||||
"dirNamesIncludeFilesSeparator": undefined,
|
||||
"escapeJson": false,
|
||||
"failOnInitialDiffError": false,
|
||||
"failOnSubmoduleDiffError": false,
|
||||
"fetchAdditionalSubmoduleHistory": false,
|
||||
"files": undefined,
|
||||
"filesFromSourceFile": undefined,
|
||||
"filesFromSourceFileSeparator": undefined,
|
||||
"filesIgnore": undefined,
|
||||
"filesIgnoreFromSourceFile": undefined,
|
||||
"filesIgnoreFromSourceFileSeparator": undefined,
|
||||
"filesIgnoreSeparator": undefined,
|
||||
"filesIgnoreYaml": undefined,
|
||||
"filesIgnoreYamlFromSourceFile": undefined,
|
||||
"filesIgnoreYamlFromSourceFileSeparator": undefined,
|
||||
"filesSeparator": undefined,
|
||||
"filesYaml": undefined,
|
||||
"filesYamlFromSourceFile": undefined,
|
||||
"filesYamlFromSourceFileSeparator": undefined,
|
||||
"includeAllOldNewRenamedFiles": false,
|
||||
"json": false,
|
||||
"negationPatternsFirst": false,
|
||||
"oldNewFilesSeparator": undefined,
|
||||
"oldNewSeparator": undefined,
|
||||
"outputDir": undefined,
|
||||
"outputRenamedFilesAsDeletedAndAdded": false,
|
||||
"path": undefined,
|
||||
"quotepath": true,
|
||||
"recoverDeletedFiles": false,
|
||||
"recoverDeletedFilesToDestination": undefined,
|
||||
"recoverFiles": undefined,
|
||||
"recoverFilesIgnore": undefined,
|
||||
"recoverFilesIgnoreSeparator": undefined,
|
||||
"recoverFilesSeparator": undefined,
|
||||
"safeOutput": false,
|
||||
"separator": undefined,
|
||||
"sha": undefined,
|
||||
"since": undefined,
|
||||
"sinceLastRemoteCommit": false,
|
||||
"skipInitialFetch": false,
|
||||
"token": undefined,
|
||||
"until": undefined,
|
||||
"useRestApi": false,
|
||||
"writeOutputFiles": false,
|
||||
}
|
||||
`;
|
153
src/__tests__/inputs.test.ts
Normal file
153
src/__tests__/inputs.test.ts
Normal file
@ -0,0 +1,153 @@
|
||||
import * as core from '@actions/core'
|
||||
import {getInputs, Inputs} from '../inputs'
|
||||
import {DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS} from '../constant'
|
||||
|
||||
jest.mock('@actions/core')
|
||||
|
||||
describe('getInputs', () => {
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
test('should return default values when no inputs are provided', () => {
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||
return g[1].toUpperCase()
|
||||
}) as keyof Inputs
|
||||
|
||||
return (DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[camelCaseName] ||
|
||||
'') as string
|
||||
})
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||
return g[1].toUpperCase()
|
||||
}) as keyof Inputs
|
||||
|
||||
return (DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[camelCaseName] ||
|
||||
false) as boolean
|
||||
})
|
||||
expect(getInputs()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should correctly parse boolean inputs', () => {
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||
return g[1].toUpperCase()
|
||||
}) as keyof Inputs
|
||||
|
||||
return (DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[camelCaseName] ||
|
||||
'') as string
|
||||
})
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
switch (name) {
|
||||
case 'matrix':
|
||||
return 'true'
|
||||
case 'skip_initial_fetch':
|
||||
return 'true'
|
||||
default:
|
||||
return 'false'
|
||||
}
|
||||
})
|
||||
expect(getInputs()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should handle matrix alias correctly', () => {
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
return name === 'matrix' ? 'true' : 'false'
|
||||
})
|
||||
|
||||
const inputs = getInputs()
|
||||
expect(inputs).toHaveProperty('json', true)
|
||||
expect(inputs).toHaveProperty('escapeJson', false)
|
||||
})
|
||||
|
||||
test('should correctly parse string inputs', () => {
|
||||
;(core.getInput as jest.Mock).mockImplementation(name => {
|
||||
switch (name) {
|
||||
case 'token':
|
||||
return 'token'
|
||||
case 'api_url':
|
||||
return 'https://api.github.com'
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
})
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||
return g[1].toUpperCase()
|
||||
}) as keyof Inputs
|
||||
|
||||
return (DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[camelCaseName] ||
|
||||
false) as boolean
|
||||
})
|
||||
expect(getInputs()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should correctly parse numeric inputs', () => {
|
||||
;(core.getInput as jest.Mock).mockImplementation(name => {
|
||||
switch (name) {
|
||||
case 'fetch_depth':
|
||||
return '5'
|
||||
case 'dir_names_max_depth':
|
||||
return '2'
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
})
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||
return g[1].toUpperCase()
|
||||
}) as keyof Inputs
|
||||
|
||||
return (DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[camelCaseName] ||
|
||||
false) as boolean
|
||||
})
|
||||
expect(getInputs()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should handle invalid numeric inputs correctly', () => {
|
||||
;(core.getInput as jest.Mock).mockImplementation(name => {
|
||||
// TODO: Add validation for invalid numbers which should result in an error instead of NaN
|
||||
switch (name) {
|
||||
case 'fetch_depth':
|
||||
return 'invalid'
|
||||
case 'dir_names_max_depth':
|
||||
return '2'
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
})
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||
return g[1].toUpperCase()
|
||||
}) as keyof Inputs
|
||||
|
||||
return (DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[camelCaseName] ||
|
||||
false) as boolean
|
||||
})
|
||||
expect(getInputs()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should handle negative numeric inputs correctly', () => {
|
||||
;(core.getInput as jest.Mock).mockImplementation(name => {
|
||||
// TODO: Add validation for negative numbers which should result in an error
|
||||
switch (name) {
|
||||
case 'fetch_depth':
|
||||
return '-5'
|
||||
case 'dir_names_max_depth':
|
||||
return '-2'
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
})
|
||||
;(core.getBooleanInput as jest.Mock).mockImplementation(name => {
|
||||
const camelCaseName = name.replace(/_([a-z])/g, (g: string[]) => {
|
||||
return g[1].toUpperCase()
|
||||
}) as keyof Inputs
|
||||
|
||||
return (DEFAULT_VALUES_OF_UNSUPPORTED_API_INPUTS[camelCaseName] ||
|
||||
false) as boolean
|
||||
})
|
||||
expect(getInputs()).toMatchSnapshot()
|
||||
})
|
||||
})
|
@ -154,8 +154,15 @@ export const getInputs = (): Inputs => {
|
||||
trimWhitespace: false
|
||||
}
|
||||
)
|
||||
const json = core.getBooleanInput('json', {required: false})
|
||||
const escapeJson = core.getBooleanInput('escape_json', {required: false})
|
||||
let json = core.getBooleanInput('json', {required: false})
|
||||
let escapeJson = core.getBooleanInput('escape_json', {required: false})
|
||||
const matrix = core.getBooleanInput('matrix', {required: false})
|
||||
|
||||
if (matrix) {
|
||||
json = true
|
||||
escapeJson = false
|
||||
}
|
||||
|
||||
const safeOutput = core.getBooleanInput('safe_output', {required: false})
|
||||
const fetchDepth = core.getInput('fetch_depth', {required: false})
|
||||
const sinceLastRemoteCommit = core.getBooleanInput(
|
||||
|
@ -681,7 +681,7 @@ export const isInsideWorkTree = async ({
|
||||
)
|
||||
|
||||
if (stdout.trim() !== 'true') {
|
||||
core.debug(
|
||||
core.warning(
|
||||
`The current working directory is not inside a git repository: ${cwd}`
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user