Skip to content

Wildcard expansion can affect INPUT_FILE_PATTERN before it's passed to git status/add #153

@ryandy

Description

@ryandy

Version of the Action
v4.9.2

Describe the bug
If INPUT_FILE_PATTERN contains a wildcard, the shell will attempt to expand it to the name(s) of matching files if they exist. This list of filenames will then be passed to git status and git add as part of _git_is_dirty() and _add_files(), instead of the originally specified string. The list of files (obtained from shell globbing) can differ from the list of files that would have matched using git pathspec.

To Reproduce

  1. Start with a repo with two files:
.
├── package
│   └── module.py
└── setup.py
  1. Modify package/module.py
  2. Run git-auto-commit-action with a file_pattern input of "*.py".
  3. See output message of "Working tree clean. Nothing to commit". This is because the shell expanded INPUT_FILE_PATTERN from "*.py" to "setup.py" before passing it to git status. Because setup.py was not modified, git status will report no change.

Expected behavior
git status should report that package/module.py was modified. And then git add should add package/module.py.

Possible fix
Running set -o noglob in entrypoint.sh will turn off glob file expansion. This could probably be run at the top of the script, but could also be run in a more local, targeted fashion, so long as it covers both the call to git status and git add.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions