clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

main
forge / test / scenarios / web-approve.sh
web-approve.sh 1.8K
1# Approve on a review page, signed in, writes the approve line forge2# approve writes, so forge.requireapproval lets main move to that tree. The3# review's author can't approve it from the web either, and approving the4# same tree twice adds nothing.5. "$(dirname "$0")/../lib.sh"6user dami7user ana8repo dami/greet9clone dami dami/greet "$T/w/dami"10at "$T/w/dami" commit "first"11ok push_as dami "$T/w/dami" origin main12git --git-dir="$FORGE_ROOT/dami/greet.git" config forge.requireapproval true13at "$T/w/dami" git switch -q -c dami/feature14at "$T/w/dami" commit "feature"15ok push_as dami "$T/w/dami" origin dami/feature16tip=$(git --git-dir="$FORGE_ROOT/dami/greet.git" rev-parse dami/feature)17export FORGE_BASE_URL=https://forge.test18private_server19ana=$(signin ana) || fail "ana can't sign in"20dami=$(signin dami) || fail "dami can't sign in"21approve() { http -s -w ' %{http_code}' -H "Cookie: __Host-forge=$1" -H 'Origin: https://forge.test' -d "at=$tip&csrf=$(csrf_of "$1")" "$PRIV/dami/greet/reviews/1/approve"; }22log=$FORGE_ROOT/dami/greet.git/forge/reviews/12324approve "$dami" >"$T/res"25has "$T/res" '"error":"you opened #1; an approval has to come from someone else"\} 400$'26lacks "$log" '^approve '27fails_with "is not approved" push_as dami "$T/w/dami" origin dami/feature:main2829approve "$ana" >"$T/res"30has "$T/res" '"ok":true,"message":"approved #1 r1 \('"$(printf %.7s "$tip")"'\): https://forge.test/dami/greet/reviews/1/"\} 200$'31has "$log" "^approve $T_NOW ana $tip $(git --git-dir="$FORGE_ROOT/dami/greet.git" rev-parse "$tip^{tree}")\$"32approve "$ana" >"$T/res"33has "$T/res" '"message":"you already approved this tree of #1"'34eq "$(grep -c '^approve ' "$log")" 135has "$FORGE_ROOT/.forge/events.jsonl" '"type":"approve","user":"ana","review":1'36ok push_as dami "$T/w/dami" origin dami/feature:main