fix: matching all nested files with a directory name (#1197)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Tonye Jack
2023-05-29 10:12:36 -06:00
committed by GitHub
parent 58c7ce2add
commit cf4fe8759a
5 changed files with 65 additions and 23 deletions

View File

@@ -265,10 +265,9 @@ export async function run(): Promise<void> {
core.debug(`All other changed files: ${allOtherChangedFiles}`)
const otherChangedFiles = allOtherChangedFiles
.split(inputs.filesSeparator)
.split(inputs.separator)
.filter(
filePath =>
!allChangedFiles.split(inputs.filesSeparator).includes(filePath)
filePath => !allChangedFiles.split(inputs.separator).includes(filePath)
)
const onlyChanged =
@@ -282,7 +281,7 @@ export async function run(): Promise<void> {
await setOutput({
key: 'other_changed_files',
value: otherChangedFiles.join(inputs.filesSeparator),
value: otherChangedFiles.join(inputs.separator),
inputs
})
@@ -318,10 +317,9 @@ export async function run(): Promise<void> {
})
const otherModifiedFiles = allOtherModifiedFiles
.split(inputs.filesSeparator)
.split(inputs.separator)
.filter(
filePath =>
!allModifiedFiles.split(inputs.filesSeparator).includes(filePath)
filePath => !allModifiedFiles.split(inputs.separator).includes(filePath)
)
const onlyModified =
@@ -335,7 +333,7 @@ export async function run(): Promise<void> {
await setOutput({
key: 'other_modified_files',
value: otherModifiedFiles.join(inputs.filesSeparator),
value: otherModifiedFiles.join(inputs.separator),
inputs
})
@@ -371,9 +369,9 @@ export async function run(): Promise<void> {
})
const otherDeletedFiles = allOtherDeletedFiles
.split(inputs.filesSeparator)
.split(inputs.separator)
.filter(
filePath => !deletedFiles.split(inputs.filesSeparator).includes(filePath)
filePath => !deletedFiles.split(inputs.separator).includes(filePath)
)
const onlyDeleted = otherDeletedFiles.length === 0 && deletedFiles.length > 0
@@ -386,7 +384,7 @@ export async function run(): Promise<void> {
await setOutput({
key: 'other_deleted_files',
value: otherDeletedFiles.join(inputs.filesSeparator),
value: otherDeletedFiles.join(inputs.separator),
inputs
})

View File

@@ -757,7 +757,23 @@ export const getFilePatterns = async ({
core.debug(`file patterns: ${filePatterns}`)
return filePatterns.trim().split('\n').filter(Boolean)
return filePatterns
.trim()
.split('\n')
.filter(Boolean)
.map(pattern => {
if (pattern.endsWith('/')) {
return `${pattern}**`
} else {
const pathParts = pattern.split('/')
const lastPart = pathParts[pathParts.length - 1]
if (!lastPart.includes('.')) {
return `${pattern}/**`
} else {
return pattern
}
}
})
}
export const setOutput = async ({