Skip to content

Commit a29f62e

Browse files
authored
fix: scripts/setup_spm.sh should handle ghost commits (#15742)
1 parent c006e03 commit a29f62e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

scripts/setup_quickstart.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,20 @@ update_spm_dependency() {
176176
*)
177177
# For PR testing, point to the current commit.
178178
local current_revision
179-
current_revision=$(git -C "$root_dir" rev-parse HEAD)
179+
180+
# Detect if we are in a PR or a regular push
181+
if [ "${GITHUB_EVENT_NAME:-}" == "pull_request" ]; then
182+
if ! command -v jq &> /dev/null; then
183+
echo "Error: jq is required for PR testing." >&2
184+
exit 1
185+
fi
186+
# In a PR, read the real commit SHA from the event payload
187+
# This guarantees a hash that exists on the remote server
188+
current_revision=$(jq -r .pull_request.head.sha "${GITHUB_EVENT_PATH}")
189+
else
190+
# In a Push (or local run), HEAD is safe to use
191+
current_revision=$(git -C "$root_dir" rev-parse HEAD)
192+
fi
180193
echo "Setting SPM dependency to current revision: ${current_revision}"
181194
"$scripts_dir/update_firebase_spm_dependency.sh" \
182195
"$absolute_project_file" --revision "$current_revision"

0 commit comments

Comments
 (0)