mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2024-11-06 02:08:05 +00:00
Merge pull request #154 from stefanzweifel/fixes/153
Add "disable_globbing" option to prevent shell from expanding filenames
This commit is contained in:
commit
4c05e3d58e
@ -70,6 +70,9 @@ This is a more extended example with all possible options.
|
||||
|
||||
# Optional: Skip internal call to `git fetch`
|
||||
skip_fetch: true
|
||||
|
||||
# Optional: Prevents the shell from expanding filenames. Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
|
||||
disable_globbing: true
|
||||
```
|
||||
|
||||
## Example
|
||||
|
@ -52,6 +52,9 @@ inputs:
|
||||
description: Skip the call to git-fetch.
|
||||
required: false
|
||||
default: false
|
||||
disable_globbing:
|
||||
description: Stop the shell from expanding filenames (https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html)
|
||||
default: false
|
||||
|
||||
outputs:
|
||||
changes_detected:
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
set -eu
|
||||
|
||||
if "$INPUT_DISABLE_GLOBBING"; then
|
||||
set -o noglob;
|
||||
fi
|
||||
|
||||
_main() {
|
||||
_switch_to_repository
|
||||
|
||||
|
@ -22,6 +22,7 @@ setup() {
|
||||
export INPUT_PUSH_OPTIONS=""
|
||||
export INPUT_SKIP_DIRTY_CHECK=false
|
||||
export INPUT_SKIP_FETCH=false
|
||||
export INPUT_DISABLE_GLOBBING=false
|
||||
|
||||
# Configure Git
|
||||
if [[ -z $(git config user.name) ]]; then
|
||||
@ -400,3 +401,38 @@ git_auto_commit() {
|
||||
|
||||
assert_equal $current_sha $remote_sha
|
||||
}
|
||||
|
||||
@test "It does not expand wildcard glob when using INPUT_PATTERN and INPUT_DISABLE_GLOBBING in git-status and git-add" {
|
||||
|
||||
# Create additional files in a nested directory structure
|
||||
echo "Create Additional files";
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-a.py
|
||||
mkdir "${FAKE_LOCAL_REPOSITORY}"/nested
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py
|
||||
|
||||
# Commit changes
|
||||
echo "Commit changes before running git_auto_commit";
|
||||
cd "${FAKE_LOCAL_REPOSITORY}";
|
||||
git add . > /dev/null;
|
||||
git commit --quiet -m "Init Remote Repository";
|
||||
git push origin master > /dev/null;
|
||||
|
||||
# Make nested file dirty
|
||||
echo "foo-bar" > "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py;
|
||||
|
||||
# ---
|
||||
|
||||
INPUT_FILE_PATTERN="*.py"
|
||||
INPUT_DISABLE_GLOBBING=true
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_FILE_PATTERN: *.py"
|
||||
assert_line "::debug::Push commit to remote branch master"
|
||||
|
||||
# Assert that the updated py file has been commited.
|
||||
run git status
|
||||
refute_output --partial 'nested/new-file-b.py'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user