fix(git-tools): validate Gitea merge API payload

This commit is contained in:
Jarvis
2026-05-26 15:05:32 -05:00
parent 43b3759ce2
commit 9547dc8b97

View File

@@ -39,6 +39,7 @@ printf '\n' >> "$PR_MERGE_TEST_LOG"
args=" $* " args=" $* "
out_file="" out_file=""
write_code=false write_code=false
post_data=""
prev="" prev=""
for arg in "$@"; do for arg in "$@"; do
if [[ "$prev" == "-o" ]]; then if [[ "$prev" == "-o" ]]; then
@@ -46,10 +47,19 @@ for arg in "$@"; do
prev="" prev=""
continue continue
fi fi
if [[ "$prev" == "-d" ]]; then
post_data="$arg"
prev=""
continue
fi
if [[ "$arg" == "-o" ]]; then if [[ "$arg" == "-o" ]]; then
prev="-o" prev="-o"
continue continue
fi fi
if [[ "$arg" == "-d" ]]; then
prev="-d"
continue
fi
if [[ "$arg" == "-w" ]]; then if [[ "$arg" == "-w" ]]; then
write_code=true write_code=true
fi fi
@@ -70,6 +80,10 @@ if [[ "$args" == *"/api/v1/repos/mosaicstack/stack/pulls/123"* && "$args" != *"/
exit 0 exit 0
fi fi
if [[ "$args" == *"-X POST"* && "$args" == *"/api/v1/repos/mosaicstack/stack/pulls/123/merge"* ]]; then if [[ "$args" == *"-X POST"* && "$args" == *"/api/v1/repos/mosaicstack/stack/pulls/123/merge"* ]]; then
if [[ "$post_data" != '{"Do":"squash"}' ]]; then
echo "unexpected merge payload: $post_data" >&2
exit 96
fi
emit_response '{"merged":true,"message":"mock merge complete"}' emit_response '{"merged":true,"message":"mock merge complete"}'
exit 0 exit 0
fi fi