@@ -7,10 +7,6 @@ base_tests_file=$(mktemp)
77
88function cleanup {
99 rm -f " $current_tests_file " " $base_tests_file "
10- # Restore any stashed changes
11- if git rev-parse --verify --quiet stash@{0} > /dev/null; then
12- git stash pop > /dev/null 2>&1
13- fi
1410}
1511trap cleanup EXIT
1612
@@ -20,11 +16,16 @@ function extract_tests() {
2016 perl -ne ' if (/^\s*test\([' \' ' "](.+?)[' \' ' "]/) { print "$1|' $file ' \n" }' " $file " 2> /dev/null
2117}
2218
23- # Stash any changes
24- git stash -u > /dev/null 2>&1 || true
25-
26- # Save current branch name
27- current_branch=$( git rev-parse --abbrev-ref HEAD)
19+ # Save current state
20+ if [ -n " $( git status --porcelain) " ]; then
21+ git config --global user.email " github-actions[bot]@users.noreply.github.com"
22+ git config --global user.name " github-actions[bot]"
23+ git add .
24+ git commit -m " temp: Save changes before test analysis" > /dev/null 2>&1
25+ need_restore=true
26+ else
27+ need_restore=false
28+ fi
2829
2930# Extract current branch tests
3031while IFS= read -r file; do
@@ -42,8 +43,11 @@ while IFS= read -r file; do
4243 fi
4344done < <( find tests/suites -type f -name " *.test.ts" ) | sort > " $base_tests_file "
4445
45- # Return to original branch
46- git checkout " $current_branch " > /dev/null 2>&1
46+ # Return to original branch and restore changes if needed
47+ git checkout - > /dev/null 2>&1
48+ if [ " $need_restore " = true ]; then
49+ git reset --soft HEAD^ > /dev/null 2>&1
50+ fi
4751
4852# Compare and collect results
4953new_tests=0
0 commit comments