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

[BUG] files_ignore input ignores negation with ! #1681

Closed
4 tasks done
luk-lo opened this issue Oct 30, 2023 · 9 comments · Fixed by #1684 or #1688
Closed
4 tasks done

[BUG] files_ignore input ignores negation with ! #1681

luk-lo opened this issue Oct 30, 2023 · 9 comments · Fixed by #1684 or #1688
Labels
bug Something isn't working

Comments

@luk-lo
Copy link

luk-lo commented Oct 30, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

I have a scenario where I want to list all changes but ignore .txt files except if those files are below module3 via the files_ignore input:

steps:
  - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
     with: 
       ref: ${{ github.event.pull_request.head.sha }}
  - name: Non-txt file changes except in module3
     id: diff-non-txt
     uses: tj-actions/changed-files@af292f1e845a0377b596972698a8598734eb2796 # v40.0.0
     with:
       files_ignore: |
         **/*.txt
         !module3/**/*.txt

But if I modify e.g. module3/test/file.txt, it does not appear in all_changed_files. The log output looks to me like the entries in files_ignore are prepended with ! except when they already have a ! in front?

To Reproduce

I reproduced the behavior in luk-lo/test-issue#1

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-22.04

Expected behavior?

I would expect the .txt files below module3 to not be ignored.

Relevant log output

##[debug]  "filesIgnore": "**/*.txt\n!module3/**/*.txt",
##[debug]  "filesIgnoreSeparator": "\n",
...
##[debug]files ignore patterns: !**/*.txt
##[debug]!module3/**/*.txt
##[debug]Input file patterns: 
##[debug]!**/*.txt
##[debug]!module3/**/*.txt
##[debug]File patterns: !**/*.txt,!module3/**/*.txt

Has all relevant logs been included?

  • I've included all relevant logs

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@luk-lo luk-lo added the bug Something isn't working label Oct 30, 2023
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@luk-lo luk-lo changed the title [BUG] ignore_files input ignores negation with ! [BUG] files_ignore input ignores negation with ! Oct 30, 2023
@jackton1
Copy link
Member

jackton1 commented Oct 30, 2023

@luk-lo The files_ignore input automatically prepends a ! to the pattern if it isn't there it doesn't conditionally allow certain patterns to the included.

If you intend to include module3/**/*.txt then you should use the files input instead. You can also include all other files with **

...
  - name: Non-txt file changes except in module3
     id: diff-non-txt
     uses: tj-actions/changed-files@af292f1e845a0377b596972698a8598734eb2796 # v40.0.0
     with:
       files: |
         **
         module3/**/*.txt
       files_ignore: '**/*.txt'

@luk-lo
Copy link
Author

luk-lo commented Oct 31, 2023

@jackton1 Thanks for the change and the quick response. My issue is that if I set files to module3/**/*.txt it restricts the selection to that pattern. I would like to check the entire repo, except for *.txt files, but include *.txt files below module3. Is that easily possible?

@jackton1
Copy link
Member

jackton1 commented Oct 31, 2023

Hi @luk-lo, yes it’s possible I’ve updated my comment above to reflect the change you’ll need to make

@luk-lo
Copy link
Author

luk-lo commented Oct 31, 2023

Hi @jackton1 thank you very much, that worked like a charm.

for the record: yaml does not like multi-line-string lines starting with ** so I had to smush it together as files: "**\nmodule3/**/*.txt"

@luk-lo
Copy link
Author

luk-lo commented Oct 31, 2023

@jackton1 sorry I spoke too early. With the new configuration, changes to .txt files outside of module3 are not ignored anymore. The ** in files overrides the **/*.txt in files_ignore in that case I think.

@jackton1 jackton1 linked a pull request Oct 31, 2023 that will close this issue
@jackton1
Copy link
Member

jackton1 commented Oct 31, 2023

Hi @luk-lo, this should be resolved now. You can re-run the workflow if you use the major version or upgrade to the latest patch release.

@luk-lo
Copy link
Author

luk-lo commented Nov 2, 2023

It works 👍 thanks again

@jackton1
Copy link
Member

jackton1 commented Nov 3, 2023

Hi @luk-lo a new release introduced a new input negation_patterns_first you’ll need to set this to true in order to get patterns to work for your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants