File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ while IFS= read -r -d $'\0' line; do
5050 # handle adds (A), modifications (M), and type changes (T):
5151 [[ " $tree_status " =~ A| M| T || " $index_status " =~ A| M| T ]] && adds+=(" $filename " )
5252
53+ # handle untracked files (??):
54+ # https://github.com/planetscale/ghcommit-action/issues/43#issuecomment-1950986790
55+ [[ " $tree_status " == " ?" && " $index_status " == " ?" ]] && adds+=(" $filename " )
56+
5357 # handle deletes (D):
5458 [[ " $tree_status " =~ D || " $index_status " =~ D ]] && deletes+=(" $filename " )
5559
Original file line number Diff line number Diff line change @@ -76,3 +76,26 @@ setup() {
7676 assert_file_exist " $GITHUB_OUTPUT "
7777 assert_file_contains " $GITHUB_OUTPUT " " commit-url=https://localhost/foo"
7878}
79+
80+ @test " handles untracked files" {
81+ local commit_message=' msg'
82+ local repo=' org/repo'
83+ local branch=' main'
84+ local empty=' false'
85+ local file_pattern=' .'
86+
87+ export GITHUB_OUTPUT=" $BATS_TEST_TMPDIR /github-output"
88+
89+ stub git \
90+ " config --global --add safe.directory $GITHUB_WORKSPACE : echo stubbed" \
91+ " status -s --porcelain=v1 -z -- . : cat ./tests/fixtures/git-status.out-2 | tr '\n' '\0'"
92+
93+ stub ghcommit \
94+ ' -b main -r org/repo -m msg --add=untracked.txt --add=new-file.md --add=modified.txt : echo Success. New commit: https://localhost/bar'
95+
96+ run ./entrypoint.sh " $commit_message " " $repo " " $branch " " $empty " " $file_pattern "
97+ assert_success
98+ assert_output --partial " Success"
99+ assert_file_exist " $GITHUB_OUTPUT "
100+ assert_file_contains " $GITHUB_OUTPUT " " commit-url=https://localhost/bar"
101+ }
Original file line number Diff line number Diff line change 1+ ?? untracked.txt
2+ ?? new-file.md
3+ M modified.txt
You can’t perform that action at this time.
0 commit comments