From 3f30970b882b0defd731aeb87ec5bbddc3b4c808 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Dec 2025 05:52:22 +0000 Subject: [PATCH 1/3] fix: handle untracked files in git status --- entrypoint.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 30c367e..80412b9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -69,6 +69,10 @@ while IFS= read -r -d $'\0' line; do # handle adds (A), modifications (M), and type changes (T): [[ "$tree_status" =~ A|M|T || "$index_status" =~ A|M|T ]] && adds+=("$filename") + # handle untracked files (??): + # https://github.com/planetscale/ghcommit-action/issues/43#issuecomment-1950986790 + [[ "$tree_status" == "?" && "$index_status" == "?" ]] && adds+=("$filename") + # handle deletes (D): [[ "$tree_status" =~ D || "$index_status" =~ D ]] && deletes+=("$filename") From 065805855083609391abe0ecce12b7884830c87c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 24 Dec 2025 05:52:23 +0000 Subject: [PATCH 2/3] fix: handle untracked files in git status --- tests/entrypoint.bats | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/entrypoint.bats b/tests/entrypoint.bats index 4f5e9ff..3787350 100644 --- a/tests/entrypoint.bats +++ b/tests/entrypoint.bats @@ -77,3 +77,26 @@ setup() { assert_file_exist "$GITHUB_OUTPUT" assert_file_contains "$GITHUB_OUTPUT" "commit-url=https://localhost/foo" } + +@test "handles untracked files" { + 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 -- . : 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' + + 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" +} From 9b7b1f286df7b17337175a8e9865764944e255ce Mon Sep 17 00:00:00 2001 From: Raj-StepSecurity Date: Wed, 24 Dec 2025 11:26:01 +0530 Subject: [PATCH 3/3] conflicted commits cherry-picked --- tests/fixtures/git-status.out-2 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/fixtures/git-status.out-2 diff --git a/tests/fixtures/git-status.out-2 b/tests/fixtures/git-status.out-2 new file mode 100644 index 0000000..6697c34 --- /dev/null +++ b/tests/fixtures/git-status.out-2 @@ -0,0 +1,3 @@ +?? untracked.txt +?? new-file.md + M modified.txt