mirror of
https://github.com/tj-actions/changed-files
synced 2025-02-20 21:01:53 +00:00
fix: matching all nested files with a directory name (#1197)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
58c7ce2add
commit
cf4fe8759a
5 changed files with 65 additions and 23 deletions
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
|
@ -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: ./
|
||||
|
|
38
dist/index.js
generated
vendored
38
dist/index.js
generated
vendored
|
@ -980,8 +980,8 @@ function run() {
|
|||
});
|
||||
core.debug(`All other changed files: ${allOtherChangedFiles}`);
|
||||
const otherChangedFiles = allOtherChangedFiles
|
||||
.split(inputs.filesSeparator)
|
||||
.filter(filePath => !allChangedFiles.split(inputs.filesSeparator).includes(filePath));
|
||||
.split(inputs.separator)
|
||||
.filter(filePath => !allChangedFiles.split(inputs.separator).includes(filePath));
|
||||
const onlyChanged = otherChangedFiles.length === 0 && allChangedFiles.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'only_changed',
|
||||
|
@ -990,7 +990,7 @@ function run() {
|
|||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'other_changed_files',
|
||||
value: otherChangedFiles.join(inputs.filesSeparator),
|
||||
value: otherChangedFiles.join(inputs.separator),
|
||||
inputs
|
||||
});
|
||||
const allModifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
||||
|
@ -1022,8 +1022,8 @@ function run() {
|
|||
submodulePaths
|
||||
});
|
||||
const otherModifiedFiles = allOtherModifiedFiles
|
||||
.split(inputs.filesSeparator)
|
||||
.filter(filePath => !allModifiedFiles.split(inputs.filesSeparator).includes(filePath));
|
||||
.split(inputs.separator)
|
||||
.filter(filePath => !allModifiedFiles.split(inputs.separator).includes(filePath));
|
||||
const onlyModified = otherModifiedFiles.length === 0 && allModifiedFiles.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'only_modified',
|
||||
|
@ -1032,7 +1032,7 @@ function run() {
|
|||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'other_modified_files',
|
||||
value: otherModifiedFiles.join(inputs.filesSeparator),
|
||||
value: otherModifiedFiles.join(inputs.separator),
|
||||
inputs
|
||||
});
|
||||
const deletedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
||||
|
@ -1064,8 +1064,8 @@ function run() {
|
|||
submodulePaths
|
||||
});
|
||||
const otherDeletedFiles = allOtherDeletedFiles
|
||||
.split(inputs.filesSeparator)
|
||||
.filter(filePath => !deletedFiles.split(inputs.filesSeparator).includes(filePath));
|
||||
.split(inputs.separator)
|
||||
.filter(filePath => !deletedFiles.split(inputs.separator).includes(filePath));
|
||||
const onlyDeleted = otherDeletedFiles.length === 0 && deletedFiles.length > 0;
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'only_deleted',
|
||||
|
@ -1074,7 +1074,7 @@ function run() {
|
|||
});
|
||||
yield (0, utils_1.setOutput)({
|
||||
key: 'other_deleted_files',
|
||||
value: otherDeletedFiles.join(inputs.filesSeparator),
|
||||
value: otherDeletedFiles.join(inputs.separator),
|
||||
inputs
|
||||
});
|
||||
if (inputs.includeAllOldNewRenamedFiles) {
|
||||
|
@ -1660,7 +1660,25 @@ const getFilePatterns = ({ inputs, workingDirectory }) => __awaiter(void 0, void
|
|||
filePatterns = filePatterns.replace(/\r/g, '\n');
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
exports.getFilePatterns = getFilePatterns;
|
||||
const setOutput = ({ key, value, inputs }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
|
|
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
20
src/main.ts
20
src/main.ts
|
@ -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
|
||||
})
|
||||
|
||||
|
|
18
src/utils.ts
18
src/utils.ts
|
@ -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 ({
|
||||
|
|
Loading…
Add table
Reference in a new issue