Skip to content

Commit cf4fe87

Browse files
fix: matching all nested files with a directory name (#1197)
Co-authored-by: GitHub Action <[email protected]>
1 parent 58c7ce2 commit cf4fe87

File tree

5 files changed

+65
-23
lines changed

5 files changed

+65
-23
lines changed

.github/workflows/test.yml

+10
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,16 @@ jobs:
508508
echo '${{ toJSON(steps.changed-files-since-last-remote-commit.outputs) }}'
509509
shell:
510510
bash
511+
- name: Run changed-files with dir name
512+
id: changed-files-dir-name
513+
uses: ./
514+
with:
515+
files: .github/workflows
516+
- name: Show output
517+
run: |
518+
echo '${{ toJSON(steps.changed-files-dir-name.outputs) }}'
519+
shell:
520+
bash
511521
- name: Run changed-files with write_output_files
512522
id: changed-files-write-output-files
513523
uses: ./

dist/index.js

+28-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,9 @@ export async function run(): Promise<void> {
265265
core.debug(`All other changed files: ${allOtherChangedFiles}`)
266266

267267
const otherChangedFiles = allOtherChangedFiles
268-
.split(inputs.filesSeparator)
268+
.split(inputs.separator)
269269
.filter(
270-
filePath =>
271-
!allChangedFiles.split(inputs.filesSeparator).includes(filePath)
270+
filePath => !allChangedFiles.split(inputs.separator).includes(filePath)
272271
)
273272

274273
const onlyChanged =
@@ -282,7 +281,7 @@ export async function run(): Promise<void> {
282281

283282
await setOutput({
284283
key: 'other_changed_files',
285-
value: otherChangedFiles.join(inputs.filesSeparator),
284+
value: otherChangedFiles.join(inputs.separator),
286285
inputs
287286
})
288287

@@ -318,10 +317,9 @@ export async function run(): Promise<void> {
318317
})
319318

320319
const otherModifiedFiles = allOtherModifiedFiles
321-
.split(inputs.filesSeparator)
320+
.split(inputs.separator)
322321
.filter(
323-
filePath =>
324-
!allModifiedFiles.split(inputs.filesSeparator).includes(filePath)
322+
filePath => !allModifiedFiles.split(inputs.separator).includes(filePath)
325323
)
326324

327325
const onlyModified =
@@ -335,7 +333,7 @@ export async function run(): Promise<void> {
335333

336334
await setOutput({
337335
key: 'other_modified_files',
338-
value: otherModifiedFiles.join(inputs.filesSeparator),
336+
value: otherModifiedFiles.join(inputs.separator),
339337
inputs
340338
})
341339

@@ -371,9 +369,9 @@ export async function run(): Promise<void> {
371369
})
372370

373371
const otherDeletedFiles = allOtherDeletedFiles
374-
.split(inputs.filesSeparator)
372+
.split(inputs.separator)
375373
.filter(
376-
filePath => !deletedFiles.split(inputs.filesSeparator).includes(filePath)
374+
filePath => !deletedFiles.split(inputs.separator).includes(filePath)
377375
)
378376

379377
const onlyDeleted = otherDeletedFiles.length === 0 && deletedFiles.length > 0
@@ -386,7 +384,7 @@ export async function run(): Promise<void> {
386384

387385
await setOutput({
388386
key: 'other_deleted_files',
389-
value: otherDeletedFiles.join(inputs.filesSeparator),
387+
value: otherDeletedFiles.join(inputs.separator),
390388
inputs
391389
})
392390

src/utils.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,23 @@ export const getFilePatterns = async ({
757757

758758
core.debug(`file patterns: ${filePatterns}`)
759759

760-
return filePatterns.trim().split('\n').filter(Boolean)
760+
return filePatterns
761+
.trim()
762+
.split('\n')
763+
.filter(Boolean)
764+
.map(pattern => {
765+
if (pattern.endsWith('/')) {
766+
return `${pattern}**`
767+
} else {
768+
const pathParts = pattern.split('/')
769+
const lastPart = pathParts[pathParts.length - 1]
770+
if (!lastPart.includes('.')) {
771+
return `${pattern}/**`
772+
} else {
773+
return pattern
774+
}
775+
}
776+
})
761777
}
762778

763779
export const setOutput = async ({

0 commit comments

Comments
 (0)