Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,16 @@ jobs:
echo '${{ toJSON(steps.changed-files-since-last-remote-commit.outputs) }}'
shell:
bash
- name: Run changed-files with dir name
id: changed-files-dir-name
uses: ./
with:
files: .github/workflows
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files-dir-name.outputs) }}'
shell:
bash
- name: Run changed-files with write_output_files
id: changed-files-write-output-files
uses: ./
Expand Down
38 changes: 28 additions & 10 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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
})

Expand Down Expand Up @@ -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 =
Expand All @@ -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
})

Expand Down Expand Up @@ -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
Expand All @@ -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
})

Expand Down
18 changes: 17 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ({
Expand Down
Loading