Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ while IFS= read -r -d $'\0' line; do
# handle deletes (D):
[[ "$tree_status" =~ D || "$index_status" =~ D ]] && deletes+=("$filename")

done < <(git status -s --porcelain=v1 -z -- "${FILE_PATTERNS[@]}")
done < <(git status -s --porcelain=v1 -z -uall -- "${FILE_PATTERNS[@]}")

if [[ "${#adds[@]}" -eq 0 && "${#deletes[@]}" -eq 0 && "$EMPTY" == "false" ]]; then
echo "No changes detected, exiting"
Expand Down
31 changes: 27 additions & 4 deletions tests/entrypoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ setup() {
# of the git status output.
stub git \
"config --global --add safe.directory $GITHUB_WORKSPACE : echo stubbed" \
"status -s --porcelain=v1 -z -- . : cat ./tests/fixtures/git-status.out-1 | tr '\n' '\0'"
"status -s --porcelain=v1 -z -uall -- . : cat ./tests/fixtures/git-status.out-1 | tr '\n' '\0'"

stub ghcommit \
'-b main -r org/repo -m msg --add=README.md --add=foo.txt --add=new.file --delete=old.file --delete=\""a path with spaces oh joy/file.txt\"" : echo Success. New commit: https://localhost/foo'
Expand All @@ -47,7 +47,7 @@ setup() {

stub git \
"config --global --add safe.directory $GITHUB_WORKSPACE : echo stubbed" \
"status -s --porcelain=v1 -z -- . : echo"
"status -s --porcelain=v1 -z -uall -- . : echo"

run ./entrypoint.sh "$commit_message" "$repo" "$branch" "$empty" "$file_pattern"
assert_success
Expand All @@ -65,7 +65,7 @@ setup() {

stub git \
"config --global --add safe.directory $GITHUB_WORKSPACE : echo stubbed" \
"status -s --porcelain=v1 -z -- . : echo"
"status -s --porcelain=v1 -z -uall -- . : echo"

stub ghcommit \
'-b main -r org/repo -m msg --empty : echo Success. New commit: https://localhost/foo'
Expand All @@ -88,7 +88,7 @@ setup() {

stub git \
"config --global --add safe.directory $GITHUB_WORKSPACE : echo stubbed" \
"status -s --porcelain=v1 -z -- . : cat ./tests/fixtures/git-status.out-2 | tr '\n' '\0'"
"status -s --porcelain=v1 -z -uall -- . : cat ./tests/fixtures/git-status.out-2 | tr '\n' '\0'"

stub ghcommit \
'-b main -r org/repo -m msg --add=untracked.txt --add=new-file.md --add=modified.txt : echo Success. New commit: https://localhost/bar'
Expand All @@ -99,3 +99,26 @@ setup() {
assert_file_exist "$GITHUB_OUTPUT"
assert_file_contains "$GITHUB_OUTPUT" "commit-url=https://localhost/bar"
}

@test "handles untracked dirs" {
local commit_message='msg'
local repo='org/repo'
local branch='main'
local empty='false'
local file_pattern='.'

export GITHUB_OUTPUT="$BATS_TEST_TMPDIR/github-output"

stub git \
"config --global --add safe.directory $GITHUB_WORKSPACE : echo stubbed" \
"status -s --porcelain=v1 -z -uall -- . : cat ./tests/fixtures/git-status.out-3 | tr '\n' '\0'"

stub ghcommit \
'-b main -r org/repo -m msg --add=newdir/file1.txt --add=newdir/file2.txt : echo Success. New commit: https://localhost/bar'

run ./entrypoint.sh "$commit_message" "$repo" "$branch" "$empty" "$file_pattern"
assert_success
assert_output --partial "Success"
assert_file_exist "$GITHUB_OUTPUT"
assert_file_contains "$GITHUB_OUTPUT" "commit-url=https://localhost/bar"
}
2 changes: 2 additions & 0 deletions tests/fixtures/git-status.out-3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
?? newdir/file1.txt
?? newdir/file2.txt