feat: move deleted file recovery to leverage filter (#1272)
This commit is contained in:
@@ -5,8 +5,9 @@ import {
|
||||
getAllChangeTypeFiles,
|
||||
getChangeTypeFiles
|
||||
} from './changedFiles'
|
||||
import {DiffResult} from './commitSha'
|
||||
import {Inputs} from './inputs'
|
||||
import {getFilteredChangedFiles, setOutput} from './utils'
|
||||
import {getFilteredChangedFiles, recoverDeletedFiles, setOutput} from './utils'
|
||||
|
||||
const getOutputKey = (key: string, outputPrefix: string): string => {
|
||||
return outputPrefix ? `${outputPrefix}_${key}` : key
|
||||
@@ -15,12 +16,16 @@ const getOutputKey = (key: string, outputPrefix: string): string => {
|
||||
export const setChangedFilesOutput = async ({
|
||||
allDiffFiles,
|
||||
inputs,
|
||||
workingDirectory,
|
||||
diffResult,
|
||||
filePatterns = [],
|
||||
outputPrefix = ''
|
||||
}: {
|
||||
allDiffFiles: ChangedFiles
|
||||
filePatterns?: string[]
|
||||
inputs: Inputs
|
||||
workingDirectory: string
|
||||
diffResult: DiffResult
|
||||
outputPrefix?: string
|
||||
}): Promise<void> => {
|
||||
const allFilteredDiffFiles = await getFilteredChangedFiles({
|
||||
@@ -29,6 +34,13 @@ export const setChangedFilesOutput = async ({
|
||||
})
|
||||
core.debug(`All filtered diff files: ${JSON.stringify(allFilteredDiffFiles)}`)
|
||||
|
||||
await recoverDeletedFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
deletedFiles: allFilteredDiffFiles[ChangeTypeEnum.Deleted],
|
||||
sha: diffResult.previousSha
|
||||
})
|
||||
|
||||
const addedFiles = await getChangeTypeFiles({
|
||||
inputs,
|
||||
changedFiles: allFilteredDiffFiles,
|
||||
|
||||
22
src/main.ts
22
src/main.ts
@@ -1,6 +1,6 @@
|
||||
import * as core from '@actions/core'
|
||||
import path from 'path'
|
||||
import {ChangeTypeEnum, getAllDiffFiles, getRenamedFiles} from './changedFiles'
|
||||
import {getAllDiffFiles, getRenamedFiles} from './changedFiles'
|
||||
import {setChangedFilesOutput} from './changedFilesOutput'
|
||||
import {
|
||||
DiffResult,
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
getSubmodulePath,
|
||||
getYamlFilePatterns,
|
||||
isRepoShallow,
|
||||
recoverDeletedFiles,
|
||||
setOutput,
|
||||
submoduleExists,
|
||||
updateGitGlobalConfig,
|
||||
@@ -119,13 +118,6 @@ export async function run(): Promise<void> {
|
||||
core.info('All Done!')
|
||||
core.endGroup()
|
||||
|
||||
await recoverDeletedFiles({
|
||||
inputs,
|
||||
workingDirectory,
|
||||
deletedFiles: allDiffFiles[ChangeTypeEnum.Deleted],
|
||||
sha: diffResult.previousSha
|
||||
})
|
||||
|
||||
const filePatterns = await getFilePatterns({
|
||||
inputs,
|
||||
workingDirectory
|
||||
@@ -137,7 +129,9 @@ export async function run(): Promise<void> {
|
||||
await setChangedFilesOutput({
|
||||
allDiffFiles,
|
||||
filePatterns,
|
||||
inputs
|
||||
inputs,
|
||||
workingDirectory,
|
||||
diffResult
|
||||
})
|
||||
core.info('All Done!')
|
||||
core.endGroup()
|
||||
@@ -155,8 +149,10 @@ export async function run(): Promise<void> {
|
||||
await setChangedFilesOutput({
|
||||
allDiffFiles,
|
||||
filePatterns: yamlFilePatterns[key],
|
||||
outputPrefix: key,
|
||||
inputs,
|
||||
outputPrefix: key
|
||||
workingDirectory,
|
||||
diffResult
|
||||
})
|
||||
core.info('All Done!')
|
||||
core.endGroup()
|
||||
@@ -167,7 +163,9 @@ export async function run(): Promise<void> {
|
||||
core.startGroup('changed-files-all')
|
||||
await setChangedFilesOutput({
|
||||
allDiffFiles,
|
||||
inputs
|
||||
inputs,
|
||||
workingDirectory,
|
||||
diffResult
|
||||
})
|
||||
core.info('All Done!')
|
||||
core.endGroup()
|
||||
|
||||
Reference in New Issue
Block a user