feat: add support for returning changed file counts (#1273)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
		
							parent
							
								
									c3c3db7fee
								
							
						
					
					
						commit
						f573054697
					
				
							
								
								
									
										30
									
								
								action.yml
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								action.yml
									
									
									
									
									
								
							| @ -157,46 +157,76 @@ inputs: | ||||
| outputs: | ||||
|   added_files: | ||||
|     description: "Returns only files that are Added (A)." | ||||
|   added_files_count: | ||||
|     description: "Returns the number of `added_files`" | ||||
|   copied_files: | ||||
|     description: "Returns only files that are Copied (C)." | ||||
|   copied_files_count: | ||||
|     description: "Returns the number of `copied_files`" | ||||
|   deleted_files: | ||||
|     description: "Returns only files that are Deleted (D)." | ||||
|   deleted_files_count: | ||||
|     description: "Returns the number of `deleted_files`" | ||||
|   modified_files: | ||||
|     description: "Returns only files that are Modified (M)." | ||||
|   modified_files_count: | ||||
|     description: "Returns the number of `modified_files`" | ||||
|   renamed_files: | ||||
|     description: "Returns only files that are Renamed (R)." | ||||
|   renamed_files_count: | ||||
|     description: "Returns the number of `renamed_files`" | ||||
|   all_old_new_renamed_files: | ||||
|     description:   "Returns only files that are Renamed and lists their old and new names. **NOTE:** This requires setting `include_all_old_new_renamed_files` to `true`. Also, keep in mind that this output is global and wouldn't be nested in outputs generated when the `*_yaml_*` input is used. (R)" | ||||
|   all_old_new_renamed_files_count: | ||||
|     description:   "Returns the number of `all_old_new_renamed_files`" | ||||
|   type_changed_files: | ||||
|     description: "Returns only files that have their file type changed (T)." | ||||
|   type_changed_files_count: | ||||
|     description: "Returns the number of `type_changed_files`" | ||||
|   unmerged_files: | ||||
|     description: "Returns only files that are Unmerged (U)." | ||||
|   unmerged_files_count: | ||||
|     description: "Returns the number of `unmerged_files`" | ||||
|   unknown_files: | ||||
|     description: "Returns only files that are Unknown (X)." | ||||
|   unknown_files_count: | ||||
|     description: "Returns the number of `unknown_files`" | ||||
|   all_changed_and_modified_files: | ||||
|     description: "Returns all changed and modified files i.e. *a combination of (ACMRDTUX)*" | ||||
|   all_changed_and_modified_files_count: | ||||
|     description: "Returns the number of `all_changed_and_modified_files`" | ||||
|   all_changed_files: | ||||
|     description: "Returns all changed files i.e. *a combination of all added, copied, modified and renamed files (ACMR)*" | ||||
|   all_changed_files_count: | ||||
|     description: "Returns the number of `all_changed_files`" | ||||
|   any_changed: | ||||
|     description: "Returns `true` when any of the filenames provided using the `files*` or `files_ignore*` inputs has changed. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*." | ||||
|   only_changed: | ||||
|     description: "Returns `true` when only files provided using the `files*` or `files_ignore*` inputs has changed. i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*." | ||||
|   other_changed_files: | ||||
|     description: "Returns all other changed files not listed in the files input i.e. *using a combination of all added, copied, modified and renamed files (ACMR)*." | ||||
|   other_changed_files_count: | ||||
|     description: "Returns the number of `other_changed_files`" | ||||
|   all_modified_files: | ||||
|     description: "Returns all changed files i.e. *a combination of all added, copied, modified, renamed and deleted files (ACMRD)*." | ||||
|   all_modified_files_count: | ||||
|     description: "Returns the number of `all_modified_files`" | ||||
|   any_modified: | ||||
|     description: "Returns `true` when any of the filenames provided using the `files*` or `files_ignore*` inputs has been modified. i.e. *using a combination of all added, copied, modified, renamed, and deleted files (ACMRD)*." | ||||
|   only_modified: | ||||
|     description: "Returns `true` when only files provided using the `files*` or `files_ignore*` inputs has been modified. (ACMRD)." | ||||
|   other_modified_files: | ||||
|     description: "Returns all other modified files not listed in the files input i.e. *a  combination of all added, copied, modified, and deleted files (ACMRD)*" | ||||
|   other_modified_files_count: | ||||
|     description: "Returns the number of `other_modified_files`" | ||||
|   any_deleted: | ||||
|     description: "Returns `true` when any of the filenames provided using the `files*` or `files_ignore*` inputs has been deleted. (D)" | ||||
|   only_deleted: | ||||
|     description: "Returns `true` when only files provided using the `files*` or `files_ignore*` inputs has been deleted. (D)" | ||||
|   other_deleted_files: | ||||
|     description: "Returns all other deleted files not listed in the files input i.e. *a  combination of all deleted files (D)*" | ||||
|   other_deleted_files_count: | ||||
|     description: "Returns the number of `other_deleted_files`" | ||||
| 
 | ||||
| runs: | ||||
|   using: 'node16' | ||||
|  | ||||
							
								
								
									
										153
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										153
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -79,9 +79,15 @@ const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, s | ||||
|         } | ||||
|     } | ||||
|     if (inputs.json) { | ||||
|         return (0, utils_1.jsonOutput)({ value: renamedFiles, shouldEscape: inputs.escapeJson }); | ||||
|         return { | ||||
|             paths: (0, utils_1.jsonOutput)({ value: renamedFiles, shouldEscape: inputs.escapeJson }), | ||||
|             count: renamedFiles.length.toString() | ||||
|         }; | ||||
|     } | ||||
|     return renamedFiles.join(inputs.oldNewFilesSeparator); | ||||
|     return { | ||||
|         paths: renamedFiles.join(inputs.oldNewFilesSeparator), | ||||
|         count: renamedFiles.length.toString() | ||||
|     }; | ||||
| }); | ||||
| exports.getRenamedFiles = getRenamedFiles; | ||||
| var ChangeTypeEnum; | ||||
| @ -157,9 +163,15 @@ const getChangeTypeFiles = ({ inputs, changedFiles, changeTypes }) => __awaiter( | ||||
|         ...new Set(getChangeTypeFilesGenerator({ inputs, changedFiles, changeTypes })) | ||||
|     ]; | ||||
|     if (inputs.json) { | ||||
|         return (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson }); | ||||
|         return { | ||||
|             paths: (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson }), | ||||
|             count: files.length.toString() | ||||
|         }; | ||||
|     } | ||||
|     return files.join(inputs.separator); | ||||
|     return { | ||||
|         paths: files.join(inputs.separator), | ||||
|         count: files.length.toString() | ||||
|     }; | ||||
| }); | ||||
| exports.getChangeTypeFiles = getChangeTypeFiles; | ||||
| function* getAllChangeTypeFilesGenerator({ inputs, changedFiles }) { | ||||
| @ -181,9 +193,15 @@ const getAllChangeTypeFiles = ({ inputs, changedFiles }) => __awaiter(void 0, vo | ||||
|         ...new Set(getAllChangeTypeFilesGenerator({ inputs, changedFiles })) | ||||
|     ]; | ||||
|     if (inputs.json) { | ||||
|         return (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson }); | ||||
|         return { | ||||
|             paths: (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson }), | ||||
|             count: files.length.toString() | ||||
|         }; | ||||
|     } | ||||
|     return files.join(inputs.separator); | ||||
|     return { | ||||
|         paths: files.join(inputs.separator), | ||||
|         count: files.length.toString() | ||||
|     }; | ||||
| }); | ||||
| exports.getAllChangeTypeFiles = getAllChangeTypeFiles; | ||||
| 
 | ||||
| @ -255,7 +273,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`Added files: ${addedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('added_files', outputPrefix), | ||||
|         value: addedFiles, | ||||
|         value: addedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('added_files_count', outputPrefix), | ||||
|         value: addedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     const copiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -266,7 +289,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`Copied files: ${copiedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('copied_files', outputPrefix), | ||||
|         value: copiedFiles, | ||||
|         value: copiedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('copied_files_count', outputPrefix), | ||||
|         value: copiedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     const modifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -277,7 +305,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`Modified files: ${modifiedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('modified_files', outputPrefix), | ||||
|         value: modifiedFiles, | ||||
|         value: modifiedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('modified_files_count', outputPrefix), | ||||
|         value: modifiedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     const renamedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -288,7 +321,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`Renamed files: ${renamedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('renamed_files', outputPrefix), | ||||
|         value: renamedFiles, | ||||
|         value: renamedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('renamed_files_count', outputPrefix), | ||||
|         value: renamedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     const typeChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -299,7 +337,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`Type changed files: ${typeChangedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('type_changed_files', outputPrefix), | ||||
|         value: typeChangedFiles, | ||||
|         value: typeChangedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('type_changed_files_count', outputPrefix), | ||||
|         value: typeChangedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     const unmergedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -310,7 +353,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`Unmerged files: ${unmergedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('unmerged_files', outputPrefix), | ||||
|         value: unmergedFiles, | ||||
|         value: unmergedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('unmerged_files_count', outputPrefix), | ||||
|         value: unmergedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     const unknownFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -321,7 +369,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`Unknown files: ${unknownFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('unknown_files', outputPrefix), | ||||
|         value: unknownFiles, | ||||
|         value: unknownFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('unknown_files_count', outputPrefix), | ||||
|         value: unknownFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     const allChangedAndModifiedFiles = yield (0, changedFiles_1.getAllChangeTypeFiles)({ | ||||
| @ -331,7 +384,12 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('all_changed_and_modified_files', outputPrefix), | ||||
|         value: allChangedAndModifiedFiles, | ||||
|         value: allChangedAndModifiedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('all_changed_and_modified_files_count', outputPrefix), | ||||
|         value: allChangedAndModifiedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     const allChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -347,12 +405,17 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`All changed files: ${allChangedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('all_changed_files', outputPrefix), | ||||
|         value: allChangedFiles, | ||||
|         value: allChangedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('all_changed_files_count', outputPrefix), | ||||
|         value: allChangedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('any_changed', outputPrefix), | ||||
|         value: allChangedFiles.length > 0 && filePatterns.length > 0, | ||||
|         value: allChangedFiles.paths.length > 0 && filePatterns.length > 0, | ||||
|         inputs | ||||
|     }); | ||||
|     const allOtherChangedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -366,11 +429,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|         ] | ||||
|     }); | ||||
|     core.debug(`All other changed files: ${allOtherChangedFiles}`); | ||||
|     const otherChangedFiles = allOtherChangedFiles | ||||
|     const otherChangedFiles = allOtherChangedFiles.paths | ||||
|         .split(inputs.separator) | ||||
|         .filter((filePath) => !allChangedFiles.split(inputs.separator).includes(filePath)); | ||||
|         .filter((filePath) => !allChangedFiles.paths.split(inputs.separator).includes(filePath)); | ||||
|     const onlyChanged = otherChangedFiles.length === 0 && | ||||
|         allChangedFiles.length > 0 && | ||||
|         allChangedFiles.paths.length > 0 && | ||||
|         filePatterns.length > 0; | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('only_changed', outputPrefix), | ||||
| @ -382,6 +445,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|         value: otherChangedFiles.join(inputs.separator), | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('other_changed_files_count', outputPrefix), | ||||
|         value: otherChangedFiles.length.toString(), | ||||
|         inputs | ||||
|     }); | ||||
|     const allModifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
|         inputs, | ||||
|         changedFiles: allFilteredDiffFiles, | ||||
| @ -396,12 +464,17 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`All modified files: ${allModifiedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('all_modified_files', outputPrefix), | ||||
|         value: allModifiedFiles, | ||||
|         value: allModifiedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('all_modified_files_count', outputPrefix), | ||||
|         value: allModifiedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('any_modified', outputPrefix), | ||||
|         value: allModifiedFiles.length > 0 && filePatterns.length > 0, | ||||
|         value: allModifiedFiles.paths.length > 0 && filePatterns.length > 0, | ||||
|         inputs | ||||
|     }); | ||||
|     const allOtherModifiedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -415,11 +488,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|             changedFiles_1.ChangeTypeEnum.Deleted | ||||
|         ] | ||||
|     }); | ||||
|     const otherModifiedFiles = allOtherModifiedFiles | ||||
|     const otherModifiedFiles = allOtherModifiedFiles.paths | ||||
|         .split(inputs.separator) | ||||
|         .filter((filePath) => !allModifiedFiles.split(inputs.separator).includes(filePath)); | ||||
|         .filter((filePath) => !allModifiedFiles.paths.split(inputs.separator).includes(filePath)); | ||||
|     const onlyModified = otherModifiedFiles.length === 0 && | ||||
|         allModifiedFiles.length > 0 && | ||||
|         allModifiedFiles.paths.length > 0 && | ||||
|         filePatterns.length > 0; | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('only_modified', outputPrefix), | ||||
| @ -431,6 +504,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|         value: otherModifiedFiles.join(inputs.separator), | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('other_modified_files_count', outputPrefix), | ||||
|         value: otherModifiedFiles.length.toString(), | ||||
|         inputs | ||||
|     }); | ||||
|     const deletedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
|         inputs, | ||||
|         changedFiles: allFilteredDiffFiles, | ||||
| @ -439,12 +517,17 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|     core.debug(`Deleted files: ${deletedFiles}`); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('deleted_files', outputPrefix), | ||||
|         value: deletedFiles, | ||||
|         value: deletedFiles.paths, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('deleted_files_count', outputPrefix), | ||||
|         value: deletedFiles.count, | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('any_deleted', outputPrefix), | ||||
|         value: deletedFiles.length > 0 && filePatterns.length > 0, | ||||
|         value: deletedFiles.paths.length > 0 && filePatterns.length > 0, | ||||
|         inputs | ||||
|     }); | ||||
|     const allOtherDeletedFiles = yield (0, changedFiles_1.getChangeTypeFiles)({ | ||||
| @ -452,11 +535,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|         changedFiles: allDiffFiles, | ||||
|         changeTypes: [changedFiles_1.ChangeTypeEnum.Deleted] | ||||
|     }); | ||||
|     const otherDeletedFiles = allOtherDeletedFiles | ||||
|     const otherDeletedFiles = allOtherDeletedFiles.paths | ||||
|         .split(inputs.separator) | ||||
|         .filter(filePath => !deletedFiles.split(inputs.separator).includes(filePath)); | ||||
|         .filter(filePath => !deletedFiles.paths.split(inputs.separator).includes(filePath)); | ||||
|     const onlyDeleted = otherDeletedFiles.length === 0 && | ||||
|         deletedFiles.length > 0 && | ||||
|         deletedFiles.paths.length > 0 && | ||||
|         filePatterns.length > 0; | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('only_deleted', outputPrefix), | ||||
| @ -468,6 +551,11 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes | ||||
|         value: otherDeletedFiles.join(inputs.separator), | ||||
|         inputs | ||||
|     }); | ||||
|     yield (0, utils_1.setOutput)({ | ||||
|         key: getOutputKey('other_deleted_files_count', outputPrefix), | ||||
|         value: otherDeletedFiles.length.toString(), | ||||
|         inputs | ||||
|     }); | ||||
| }); | ||||
| exports.setChangedFilesOutput = setChangedFilesOutput; | ||||
| 
 | ||||
| @ -1305,7 +1393,12 @@ function run() { | ||||
|             core.debug(`All old new renamed files: ${allOldNewRenamedFiles}`); | ||||
|             yield (0, utils_1.setOutput)({ | ||||
|                 key: 'all_old_new_renamed_files', | ||||
|                 value: allOldNewRenamedFiles, | ||||
|                 value: allOldNewRenamedFiles.paths, | ||||
|                 inputs | ||||
|             }); | ||||
|             yield (0, utils_1.setOutput)({ | ||||
|                 key: 'all_old_new_renamed_files_count', | ||||
|                 value: allOldNewRenamedFiles.count, | ||||
|                 inputs | ||||
|             }); | ||||
|             core.info('All Done!'); | ||||
|  | ||||
							
								
								
									
										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
											
										
									
								
							| @ -23,7 +23,7 @@ export const getRenamedFiles = async ({ | ||||
|   hasSubmodule: boolean | ||||
|   diffResult: DiffResult | ||||
|   submodulePaths: string[] | ||||
| }): Promise<string> => { | ||||
| }): Promise<{paths: string; count: string}> => { | ||||
|   const renamedFiles = await gitRenamedFiles({ | ||||
|     cwd: workingDirectory, | ||||
|     sha1: diffResult.previousSha, | ||||
| @ -63,10 +63,16 @@ export const getRenamedFiles = async ({ | ||||
|   } | ||||
| 
 | ||||
|   if (inputs.json) { | ||||
|     return jsonOutput({value: renamedFiles, shouldEscape: inputs.escapeJson}) | ||||
|     return { | ||||
|       paths: jsonOutput({value: renamedFiles, shouldEscape: inputs.escapeJson}), | ||||
|       count: renamedFiles.length.toString() | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   return renamedFiles.join(inputs.oldNewFilesSeparator) | ||||
|   return { | ||||
|     paths: renamedFiles.join(inputs.oldNewFilesSeparator), | ||||
|     count: renamedFiles.length.toString() | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| export enum ChangeTypeEnum { | ||||
| @ -180,16 +186,22 @@ export const getChangeTypeFiles = async ({ | ||||
|   inputs: Inputs | ||||
|   changedFiles: ChangedFiles | ||||
|   changeTypes: ChangeTypeEnum[] | ||||
| }): Promise<string> => { | ||||
| }): Promise<{paths: string; count: string}> => { | ||||
|   const files = [ | ||||
|     ...new Set(getChangeTypeFilesGenerator({inputs, changedFiles, changeTypes})) | ||||
|   ] | ||||
| 
 | ||||
|   if (inputs.json) { | ||||
|     return jsonOutput({value: files, shouldEscape: inputs.escapeJson}) | ||||
|     return { | ||||
|       paths: jsonOutput({value: files, shouldEscape: inputs.escapeJson}), | ||||
|       count: files.length.toString() | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   return files.join(inputs.separator) | ||||
|   return { | ||||
|     paths: files.join(inputs.separator), | ||||
|     count: files.length.toString() | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| function* getAllChangeTypeFilesGenerator({ | ||||
| @ -219,14 +231,20 @@ export const getAllChangeTypeFiles = async ({ | ||||
| }: { | ||||
|   inputs: Inputs | ||||
|   changedFiles: ChangedFiles | ||||
| }): Promise<string> => { | ||||
| }): Promise<{paths: string; count: string}> => { | ||||
|   const files = [ | ||||
|     ...new Set(getAllChangeTypeFilesGenerator({inputs, changedFiles})) | ||||
|   ] | ||||
| 
 | ||||
|   if (inputs.json) { | ||||
|     return jsonOutput({value: files, shouldEscape: inputs.escapeJson}) | ||||
|     return { | ||||
|       paths: jsonOutput({value: files, shouldEscape: inputs.escapeJson}), | ||||
|       count: files.length.toString() | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   return files.join(inputs.separator) | ||||
|   return { | ||||
|     paths: files.join(inputs.separator), | ||||
|     count: files.length.toString() | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -49,7 +49,12 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`Added files: ${addedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('added_files', outputPrefix), | ||||
|     value: addedFiles, | ||||
|     value: addedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('added_files_count', outputPrefix), | ||||
|     value: addedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -61,7 +66,13 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`Copied files: ${copiedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('copied_files', outputPrefix), | ||||
|     value: copiedFiles, | ||||
|     value: copiedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('copied_files_count', outputPrefix), | ||||
|     value: copiedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -73,7 +84,13 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`Modified files: ${modifiedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('modified_files', outputPrefix), | ||||
|     value: modifiedFiles, | ||||
|     value: modifiedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('modified_files_count', outputPrefix), | ||||
|     value: modifiedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -85,7 +102,13 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`Renamed files: ${renamedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('renamed_files', outputPrefix), | ||||
|     value: renamedFiles, | ||||
|     value: renamedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('renamed_files_count', outputPrefix), | ||||
|     value: renamedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -97,7 +120,13 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`Type changed files: ${typeChangedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('type_changed_files', outputPrefix), | ||||
|     value: typeChangedFiles, | ||||
|     value: typeChangedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('type_changed_files_count', outputPrefix), | ||||
|     value: typeChangedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -109,7 +138,13 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`Unmerged files: ${unmergedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('unmerged_files', outputPrefix), | ||||
|     value: unmergedFiles, | ||||
|     value: unmergedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('unmerged_files_count', outputPrefix), | ||||
|     value: unmergedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -121,7 +156,13 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`Unknown files: ${unknownFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('unknown_files', outputPrefix), | ||||
|     value: unknownFiles, | ||||
|     value: unknownFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('unknown_files_count', outputPrefix), | ||||
|     value: unknownFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -132,7 +173,13 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('all_changed_and_modified_files', outputPrefix), | ||||
|     value: allChangedAndModifiedFiles, | ||||
|     value: allChangedAndModifiedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('all_changed_and_modified_files_count', outputPrefix), | ||||
|     value: allChangedAndModifiedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -149,13 +196,19 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`All changed files: ${allChangedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('all_changed_files', outputPrefix), | ||||
|     value: allChangedFiles, | ||||
|     value: allChangedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('all_changed_files_count', outputPrefix), | ||||
|     value: allChangedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('any_changed', outputPrefix), | ||||
|     value: allChangedFiles.length > 0 && filePatterns.length > 0, | ||||
|     value: allChangedFiles.paths.length > 0 && filePatterns.length > 0, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -171,16 +224,16 @@ export const setChangedFilesOutput = async ({ | ||||
|   }) | ||||
|   core.debug(`All other changed files: ${allOtherChangedFiles}`) | ||||
| 
 | ||||
|   const otherChangedFiles = allOtherChangedFiles | ||||
|   const otherChangedFiles = allOtherChangedFiles.paths | ||||
|     .split(inputs.separator) | ||||
|     .filter( | ||||
|       (filePath: string) => | ||||
|         !allChangedFiles.split(inputs.separator).includes(filePath) | ||||
|         !allChangedFiles.paths.split(inputs.separator).includes(filePath) | ||||
|     ) | ||||
| 
 | ||||
|   const onlyChanged = | ||||
|     otherChangedFiles.length === 0 && | ||||
|     allChangedFiles.length > 0 && | ||||
|     allChangedFiles.paths.length > 0 && | ||||
|     filePatterns.length > 0 | ||||
| 
 | ||||
|   await setOutput({ | ||||
| @ -195,6 +248,12 @@ export const setChangedFilesOutput = async ({ | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('other_changed_files_count', outputPrefix), | ||||
|     value: otherChangedFiles.length.toString(), | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   const allModifiedFiles = await getChangeTypeFiles({ | ||||
|     inputs, | ||||
|     changedFiles: allFilteredDiffFiles, | ||||
| @ -209,13 +268,19 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`All modified files: ${allModifiedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('all_modified_files', outputPrefix), | ||||
|     value: allModifiedFiles, | ||||
|     value: allModifiedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('all_modified_files_count', outputPrefix), | ||||
|     value: allModifiedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('any_modified', outputPrefix), | ||||
|     value: allModifiedFiles.length > 0 && filePatterns.length > 0, | ||||
|     value: allModifiedFiles.paths.length > 0 && filePatterns.length > 0, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -231,16 +296,16 @@ export const setChangedFilesOutput = async ({ | ||||
|     ] | ||||
|   }) | ||||
| 
 | ||||
|   const otherModifiedFiles = allOtherModifiedFiles | ||||
|   const otherModifiedFiles = allOtherModifiedFiles.paths | ||||
|     .split(inputs.separator) | ||||
|     .filter( | ||||
|       (filePath: string) => | ||||
|         !allModifiedFiles.split(inputs.separator).includes(filePath) | ||||
|         !allModifiedFiles.paths.split(inputs.separator).includes(filePath) | ||||
|     ) | ||||
| 
 | ||||
|   const onlyModified = | ||||
|     otherModifiedFiles.length === 0 && | ||||
|     allModifiedFiles.length > 0 && | ||||
|     allModifiedFiles.paths.length > 0 && | ||||
|     filePatterns.length > 0 | ||||
| 
 | ||||
|   await setOutput({ | ||||
| @ -255,6 +320,12 @@ export const setChangedFilesOutput = async ({ | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('other_modified_files_count', outputPrefix), | ||||
|     value: otherModifiedFiles.length.toString(), | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   const deletedFiles = await getChangeTypeFiles({ | ||||
|     inputs, | ||||
|     changedFiles: allFilteredDiffFiles, | ||||
| @ -263,13 +334,19 @@ export const setChangedFilesOutput = async ({ | ||||
|   core.debug(`Deleted files: ${deletedFiles}`) | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('deleted_files', outputPrefix), | ||||
|     value: deletedFiles, | ||||
|     value: deletedFiles.paths, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('deleted_files_count', outputPrefix), | ||||
|     value: deletedFiles.count, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('any_deleted', outputPrefix), | ||||
|     value: deletedFiles.length > 0 && filePatterns.length > 0, | ||||
|     value: deletedFiles.paths.length > 0 && filePatterns.length > 0, | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
| @ -279,15 +356,15 @@ export const setChangedFilesOutput = async ({ | ||||
|     changeTypes: [ChangeTypeEnum.Deleted] | ||||
|   }) | ||||
| 
 | ||||
|   const otherDeletedFiles = allOtherDeletedFiles | ||||
|   const otherDeletedFiles = allOtherDeletedFiles.paths | ||||
|     .split(inputs.separator) | ||||
|     .filter( | ||||
|       filePath => !deletedFiles.split(inputs.separator).includes(filePath) | ||||
|       filePath => !deletedFiles.paths.split(inputs.separator).includes(filePath) | ||||
|     ) | ||||
| 
 | ||||
|   const onlyDeleted = | ||||
|     otherDeletedFiles.length === 0 && | ||||
|     deletedFiles.length > 0 && | ||||
|     deletedFiles.paths.length > 0 && | ||||
|     filePatterns.length > 0 | ||||
| 
 | ||||
|   await setOutput({ | ||||
| @ -301,4 +378,10 @@ export const setChangedFilesOutput = async ({ | ||||
|     value: otherDeletedFiles.join(inputs.separator), | ||||
|     inputs | ||||
|   }) | ||||
| 
 | ||||
|   await setOutput({ | ||||
|     key: getOutputKey('other_deleted_files_count', outputPrefix), | ||||
|     value: otherDeletedFiles.length.toString(), | ||||
|     inputs | ||||
|   }) | ||||
| } | ||||
|  | ||||
| @ -183,7 +183,12 @@ export async function run(): Promise<void> { | ||||
|     core.debug(`All old new renamed files: ${allOldNewRenamedFiles}`) | ||||
|     await setOutput({ | ||||
|       key: 'all_old_new_renamed_files', | ||||
|       value: allOldNewRenamedFiles, | ||||
|       value: allOldNewRenamedFiles.paths, | ||||
|       inputs | ||||
|     }) | ||||
|     await setOutput({ | ||||
|       key: 'all_old_new_renamed_files_count', | ||||
|       value: allOldNewRenamedFiles.count, | ||||
|       inputs | ||||
|     }) | ||||
|     core.info('All Done!') | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tonye Jack
						Tonye Jack