tj-actions / changed-files

:octocat: Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.
MIT License
1.77k stars 191 forks source link

[BUG] Glob vs regex in readme and execution when using * in with: files: #200

Closed adamsilkcm closed 2 years ago

adamsilkcm commented 2 years ago

Is there an existing issue for this?

Describe the bug?

The readme currently contains:

      - name: Get specific changed files
        id: changed-files-specific
        uses: tj-actions/changed-files@v1.1.3
        with:
          files: |
            my-file.txt
            test.txt
            new.txt
            test_directory
            *.sh
            .(png|jpeg)$
            .(sql)$
            ^(mynewfile|custom)

These examples are utilizing behavior undefined in the ERE

The asterisk, plus-sign, question-mark, and left-brace shall be special except when used in a bracket expression (see RE Bracket Expression). Any of the following uses produce undefined results: If these characters appear first in an ERE, or immediately following an unescaped vertical-line, circumflex, dollar-sign, or left-parenthesis

GNU Grep allows them to be a part of EREs, but this can cause issues when it's used by other parts of the entrypoint script.

To Reproduce

Given a directory structure such as

├── directory
│   └── child_dir.sh
└── root_dir.sh

and an action such as

      - name: get changed files
        id: changed_files
        uses: tj-actions/changed-files@v1.1.3
        with:
          files: |
            *.sh

output shows *.sh gets expanded by the bash entrypoint script as a glob:

[...]
Checking for file changes: "root_dir.sh"...
[...]
Matching modified files: 
Non Matching modified files:  root_dir.sh directory/child_dir.sh

as opposed to the expected

[...]
  Checking for file changes: "*.sh"...
[...]
Matching modified files: root_dir.sh directory/child_dir.sh
Non Matching modified files:

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

If *.sh is in the examples, it should work to find any files with .sh in them. If not, it should be removed from the examples along with .

Variables with expected special characters should be quoted to prevent globbing when using them in output.

Relevant log output

No response

Anything else?

For the *.sh example, .*\.sh works as a replacement.

https://www.gnu.org/software/grep/manual/html_node/Basic-vs-Extended.html

Code of Conduct

jackton1 commented 2 years ago

@adamsilkcm Updated the README to avoid confusion. Thanks