2023-06-16 06:17:13 +00:00
|
|
|
import * as core from '@actions/core'
|
2023-09-22 02:47:12 +00:00
|
|
|
import path from 'path'
|
2023-06-16 06:17:13 +00:00
|
|
|
import {
|
|
|
|
ChangedFiles,
|
|
|
|
ChangeTypeEnum,
|
|
|
|
getAllChangeTypeFiles,
|
|
|
|
getChangeTypeFiles
|
|
|
|
} from './changedFiles'
|
|
|
|
import {Inputs} from './inputs'
|
2023-09-22 02:47:12 +00:00
|
|
|
import {getOutputKey, setArrayOutput, setOutput, exists} from './utils'
|
2023-06-16 06:17:13 +00:00
|
|
|
|
2023-09-04 20:03:32 +00:00
|
|
|
const getArrayFromPaths = (
|
|
|
|
paths: string | string[],
|
|
|
|
inputs: Inputs
|
|
|
|
): string[] => {
|
|
|
|
return Array.isArray(paths) ? paths : paths.split(inputs.separator)
|
|
|
|
}
|
|
|
|
|
2023-09-18 20:17:46 +00:00
|
|
|
export const setOutputsAndGetModifiedAndChangedFilesStatus = async ({
|
2023-06-16 06:17:13 +00:00
|
|
|
allDiffFiles,
|
2023-08-07 06:00:11 +00:00
|
|
|
allFilteredDiffFiles,
|
2023-06-16 06:17:13 +00:00
|
|
|
inputs,
|
|
|
|
filePatterns = [],
|
2023-09-22 02:47:12 +00:00
|
|
|
outputPrefix = '',
|
|
|
|
workingDirectory
|
2023-06-16 06:17:13 +00:00
|
|
|
}: {
|
|
|
|
allDiffFiles: ChangedFiles
|
2023-08-07 06:00:11 +00:00
|
|
|
allFilteredDiffFiles: ChangedFiles
|
2023-06-16 06:17:13 +00:00
|
|
|
inputs: Inputs
|
2023-06-23 17:20:13 +00:00
|
|
|
filePatterns?: string[]
|
2023-06-16 06:17:13 +00:00
|
|
|
outputPrefix?: string
|
2023-09-22 02:47:12 +00:00
|
|
|
workingDirectory?: string
|
2023-09-18 20:17:46 +00:00
|
|
|
}): Promise<{anyModified: boolean; anyChanged: boolean}> => {
|
2023-06-16 06:17:13 +00:00
|
|
|
const addedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.Added]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`Added files: ${JSON.stringify(addedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('added_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: addedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('added_files_count', outputPrefix),
|
|
|
|
value: addedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const copiedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.Copied]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`Copied files: ${JSON.stringify(copiedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('copied_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: copiedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('copied_files_count', outputPrefix),
|
|
|
|
value: copiedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const modifiedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.Modified]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`Modified files: ${JSON.stringify(modifiedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('modified_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: modifiedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('modified_files_count', outputPrefix),
|
|
|
|
value: modifiedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const renamedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.Renamed]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`Renamed files: ${JSON.stringify(renamedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('renamed_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: renamedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('renamed_files_count', outputPrefix),
|
|
|
|
value: renamedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const typeChangedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.TypeChanged]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`Type changed files: ${JSON.stringify(typeChangedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('type_changed_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: typeChangedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('type_changed_files_count', outputPrefix),
|
|
|
|
value: typeChangedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const unmergedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.Unmerged]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`Unmerged files: ${JSON.stringify(unmergedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('unmerged_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: unmergedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('unmerged_files_count', outputPrefix),
|
|
|
|
value: unmergedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const unknownFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.Unknown]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`Unknown files: ${JSON.stringify(unknownFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('unknown_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: unknownFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('unknown_files_count', outputPrefix),
|
|
|
|
value: unknownFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const allChangedAndModifiedFiles = await getAllChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(
|
|
|
|
`All changed and modified files: ${JSON.stringify(
|
|
|
|
allChangedAndModifiedFiles
|
|
|
|
)}`
|
|
|
|
)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('all_changed_and_modified_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: allChangedAndModifiedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('all_changed_and_modified_files_count', outputPrefix),
|
|
|
|
value: allChangedAndModifiedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const allChangedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [
|
|
|
|
ChangeTypeEnum.Added,
|
|
|
|
ChangeTypeEnum.Copied,
|
|
|
|
ChangeTypeEnum.Modified,
|
|
|
|
ChangeTypeEnum.Renamed
|
|
|
|
]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`All changed files: ${JSON.stringify(allChangedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('all_changed_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: allChangedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('all_changed_files_count', outputPrefix),
|
|
|
|
value: allChangedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('any_changed', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: allChangedFiles.paths.length > 0 && filePatterns.length > 0,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const allOtherChangedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allDiffFiles,
|
|
|
|
changeTypes: [
|
|
|
|
ChangeTypeEnum.Added,
|
|
|
|
ChangeTypeEnum.Copied,
|
|
|
|
ChangeTypeEnum.Modified,
|
|
|
|
ChangeTypeEnum.Renamed
|
|
|
|
]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`All other changed files: ${JSON.stringify(allOtherChangedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
|
2023-09-04 20:03:32 +00:00
|
|
|
const allOtherChangedFilesPaths: string[] = getArrayFromPaths(
|
|
|
|
allOtherChangedFiles.paths,
|
|
|
|
inputs
|
|
|
|
)
|
|
|
|
const allChangedFilesPaths: string[] = getArrayFromPaths(
|
|
|
|
allChangedFiles.paths,
|
|
|
|
inputs
|
|
|
|
)
|
|
|
|
|
|
|
|
const otherChangedFiles = allOtherChangedFilesPaths.filter(
|
|
|
|
(filePath: string) => !allChangedFilesPaths.includes(filePath)
|
|
|
|
)
|
2023-06-16 06:17:13 +00:00
|
|
|
|
|
|
|
const onlyChanged =
|
|
|
|
otherChangedFiles.length === 0 &&
|
2023-06-17 03:13:40 +00:00
|
|
|
allChangedFiles.paths.length > 0 &&
|
2023-06-16 06:17:13 +00:00
|
|
|
filePatterns.length > 0
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('only_changed', outputPrefix),
|
|
|
|
value: onlyChanged,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
2023-09-19 19:18:22 +00:00
|
|
|
await setArrayOutput({
|
|
|
|
key: 'other_changed_files',
|
|
|
|
inputs,
|
|
|
|
value: otherChangedFiles,
|
|
|
|
outputPrefix
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
2023-06-17 03:13:40 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('other_changed_files_count', outputPrefix),
|
|
|
|
value: otherChangedFiles.length.toString(),
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
2023-06-16 06:17:13 +00:00
|
|
|
const allModifiedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [
|
|
|
|
ChangeTypeEnum.Added,
|
|
|
|
ChangeTypeEnum.Copied,
|
|
|
|
ChangeTypeEnum.Modified,
|
|
|
|
ChangeTypeEnum.Renamed,
|
|
|
|
ChangeTypeEnum.Deleted
|
|
|
|
]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`All modified files: ${JSON.stringify(allModifiedFiles)}`)
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('all_modified_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: allModifiedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('all_modified_files_count', outputPrefix),
|
|
|
|
value: allModifiedFiles.count,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('any_modified', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: allModifiedFiles.paths.length > 0 && filePatterns.length > 0,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const allOtherModifiedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allDiffFiles,
|
|
|
|
changeTypes: [
|
|
|
|
ChangeTypeEnum.Added,
|
|
|
|
ChangeTypeEnum.Copied,
|
|
|
|
ChangeTypeEnum.Modified,
|
|
|
|
ChangeTypeEnum.Renamed,
|
|
|
|
ChangeTypeEnum.Deleted
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2023-09-04 20:03:32 +00:00
|
|
|
const allOtherModifiedFilesPaths: string[] = getArrayFromPaths(
|
|
|
|
allOtherModifiedFiles.paths,
|
|
|
|
inputs
|
|
|
|
)
|
|
|
|
|
|
|
|
const allModifiedFilesPaths: string[] = getArrayFromPaths(
|
|
|
|
allModifiedFiles.paths,
|
|
|
|
inputs
|
|
|
|
)
|
|
|
|
|
|
|
|
const otherModifiedFiles = allOtherModifiedFilesPaths.filter(
|
|
|
|
(filePath: string) => !allModifiedFilesPaths.includes(filePath)
|
|
|
|
)
|
2023-06-16 06:17:13 +00:00
|
|
|
|
|
|
|
const onlyModified =
|
|
|
|
otherModifiedFiles.length === 0 &&
|
2023-06-17 03:13:40 +00:00
|
|
|
allModifiedFiles.paths.length > 0 &&
|
2023-06-16 06:17:13 +00:00
|
|
|
filePatterns.length > 0
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('only_modified', outputPrefix),
|
|
|
|
value: onlyModified,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
2023-09-19 19:18:22 +00:00
|
|
|
await setArrayOutput({
|
|
|
|
key: 'other_modified_files',
|
|
|
|
inputs,
|
|
|
|
value: otherModifiedFiles,
|
|
|
|
outputPrefix
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
2023-06-17 03:13:40 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('other_modified_files_count', outputPrefix),
|
|
|
|
value: otherModifiedFiles.length.toString(),
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
2023-06-16 06:17:13 +00:00
|
|
|
const deletedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allFilteredDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.Deleted]
|
|
|
|
})
|
2023-07-18 09:44:59 +00:00
|
|
|
core.debug(`Deleted files: ${JSON.stringify(deletedFiles)}`)
|
2023-09-22 02:47:12 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
inputs.dirNamesDeletedFilesIncludeOnlyDeletedDirs &&
|
|
|
|
inputs.dirNames &&
|
|
|
|
workingDirectory
|
|
|
|
) {
|
2023-09-22 15:56:45 +00:00
|
|
|
const newDeletedFilesPaths: string[] = []
|
2023-09-22 02:47:12 +00:00
|
|
|
for (const deletedPath of getArrayFromPaths(deletedFiles.paths, inputs)) {
|
|
|
|
if (!(await exists(path.join(workingDirectory, deletedPath)))) {
|
2023-09-22 15:56:45 +00:00
|
|
|
newDeletedFilesPaths.push(deletedPath)
|
2023-09-22 02:47:12 +00:00
|
|
|
}
|
|
|
|
}
|
2023-09-22 15:56:45 +00:00
|
|
|
deletedFiles.paths = inputs.json
|
|
|
|
? newDeletedFilesPaths
|
|
|
|
: newDeletedFilesPaths.join(inputs.separator)
|
|
|
|
deletedFiles.count = newDeletedFilesPaths.length.toString()
|
2023-09-22 02:47:12 +00:00
|
|
|
}
|
|
|
|
|
2023-09-22 15:56:45 +00:00
|
|
|
const deletedFilesPaths: string[] = getArrayFromPaths(
|
|
|
|
deletedFiles.paths,
|
|
|
|
inputs
|
|
|
|
)
|
|
|
|
const deletedFilesCount = deletedFilesPaths.length.toString()
|
|
|
|
|
2023-06-16 06:17:13 +00:00
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('deleted_files', outputPrefix),
|
2023-06-17 03:13:40 +00:00
|
|
|
value: deletedFiles.paths,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json,
|
|
|
|
shouldEscape: inputs.escapeJson
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('deleted_files_count', outputPrefix),
|
2023-09-22 15:56:45 +00:00
|
|
|
value: deletedFilesCount,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('any_deleted', outputPrefix),
|
2023-09-22 15:56:45 +00:00
|
|
|
value: deletedFilesPaths.length > 0 && filePatterns.length > 0,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const allOtherDeletedFiles = await getChangeTypeFiles({
|
|
|
|
inputs,
|
|
|
|
changedFiles: allDiffFiles,
|
|
|
|
changeTypes: [ChangeTypeEnum.Deleted]
|
|
|
|
})
|
|
|
|
|
2023-09-04 20:03:32 +00:00
|
|
|
const allOtherDeletedFilesPaths: string[] = getArrayFromPaths(
|
|
|
|
allOtherDeletedFiles.paths,
|
|
|
|
inputs
|
|
|
|
)
|
|
|
|
|
|
|
|
const otherDeletedFiles = allOtherDeletedFilesPaths.filter(
|
|
|
|
filePath => !deletedFilesPaths.includes(filePath)
|
|
|
|
)
|
2023-06-16 06:17:13 +00:00
|
|
|
|
|
|
|
const onlyDeleted =
|
|
|
|
otherDeletedFiles.length === 0 &&
|
2023-06-17 03:13:40 +00:00
|
|
|
deletedFiles.paths.length > 0 &&
|
2023-06-16 06:17:13 +00:00
|
|
|
filePatterns.length > 0
|
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('only_deleted', outputPrefix),
|
|
|
|
value: onlyDeleted,
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir,
|
|
|
|
json: inputs.json
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
|
|
|
|
2023-09-19 19:18:22 +00:00
|
|
|
await setArrayOutput({
|
|
|
|
key: 'other_deleted_files',
|
|
|
|
inputs,
|
|
|
|
value: otherDeletedFiles,
|
|
|
|
outputPrefix
|
2023-06-16 06:17:13 +00:00
|
|
|
})
|
2023-06-17 03:13:40 +00:00
|
|
|
|
|
|
|
await setOutput({
|
|
|
|
key: getOutputKey('other_deleted_files_count', outputPrefix),
|
|
|
|
value: otherDeletedFiles.length.toString(),
|
2023-09-04 20:03:32 +00:00
|
|
|
writeOutputFiles: inputs.writeOutputFiles,
|
|
|
|
outputDir: inputs.outputDir
|
2023-06-17 03:13:40 +00:00
|
|
|
})
|
2023-09-18 20:17:46 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
anyModified: allModifiedFiles.paths.length > 0 && filePatterns.length > 0,
|
|
|
|
anyChanged: allChangedFiles.paths.length > 0 && filePatterns.length > 0
|
|
|
|
}
|
2023-06-16 06:17:13 +00:00
|
|
|
}
|