24 lines
624 B
Bash
24 lines
624 B
Bash
#!/usr/bin/env bash
|
|||
|
|
# Gitea API stub for cascade.sh tests: logs each call, answers CURL_STATUS.
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
out="" data="" url="" method=GET
|
||
|
|
while [ "$#" -gt 0 ]; do
|
||
|
|
case "$1" in
|
||
|
|
-o) out="$2"; shift 2 ;;
|
||
|
|
-X) method="$2"; shift 2 ;;
|
||
|
|
--data) data="$2"; shift 2 ;;
|
||
|
|
-w|-H) shift 2 ;;
|
||
|
|
http*) url="$1"; shift ;;
|
||
|
|
*) shift ;;
|
||
|
|
esac
|
||
|
|
done
|
||
|
|
|
||
|
|
printf '%s %s %s\n' "$method" "$url" "$data" >>"${CURL_LOG}"
|
||
|
|
status="${CURL_STATUS:-201}"
|
||
|
|
if [ "$status" = 201 ]; then
|
||
|
|
printf '{"html_url":"https://code.test/pulls/7"}' >"$out"
|
||
|
|
else
|
||
|
|
printf '{"message":"stub %s"}' "$status" >"$out"
|
||
|
|
fi
|
||
|
|
printf '%s' "$status"
|