1# A review page posts the tip it shows. When the review has moved on since2# the page was built, a comment from it belongs to the revision it showed,3# as one from a checkout of that revision does, and an approval from it is4# refused. A tip the review never had is refused too. The forge words5# these refusals for a page (reload it); over ssh they still say to check6# out or push.7. "$(dirname "$0")/../lib.sh"8user dami9user ana10repo dami/greet11clone dami dami/greet "$T/w/dami"12at "$T/w/dami" commit "first"13ok push_as dami "$T/w/dami" origin main14at "$T/w/dami" git switch -q -c dami/feature15at "$T/w/dami" commit "feature" greet.sh16ok push_as dami "$T/w/dami" origin dami/feature17r1=$(git --git-dir="$FORGE_ROOT/dami/greet.git" rev-parse dami/feature)18at "$T/w/dami" commit "more" greet.sh19ok push_as dami "$T/w/dami" origin dami/feature20r2=$(git --git-dir="$FORGE_ROOT/dami/greet.git" rev-parse dami/feature)21export FORGE_BASE_URL=https://forge.test22private_server23ana=$(signin ana) || fail "ana can't sign in"24csrf=$(csrf_of "$ana")25post() { http -s -w ' %{http_code}' -H "Cookie: __Host-forge=$ana" -H 'Origin: https://forge.test' -d "$2&csrf=$csrf" "$PRIV/dami/greet/reviews/1/$1"; }26d=$FORGE_ROOT/dami/greet.git/forge/comments/12728post comment "body=On the first&at=$r1&line=greet.sh:1" >"$T/res"29has "$T/res" '"message":"comment 1 on #1 r1: https://forge.test/dami/greet/reviews/1/#comment-1\\n\(#1 has a newer revision, so this shows as outdated\)"'30has "$d/1" "^sha $r1\$"31has "$d/1" '^rev 1$'32post comment "body=On the second&at=$r2" >"$T/res"33has "$d/2" "^sha $r2\$"34has "$d/2" '^rev 2$'3536post approve "at=$r1" >"$T/res"37has "$T/res" "\"error\":\"#1 has moved on to r2 $(printf %.7s "$r2") since $(printf %.7s "$r1"); reload the page to see what changed, and approve that\"\\} 400\$"38fails_with "^forge: #1 has moved on to r2 $(printf %.7s "$r2") since $(printf %.7s "$r1"); run forge checkout 1 and look again\$" ssh_as ana approve dami/greet 1 --at "$r1"39lacks "$FORGE_ROOT/dami/greet.git/forge/reviews/1" '^approve '40main=$(git --git-dir="$FORGE_ROOT/dami/greet.git" rev-parse main)41post comment "body=Nowhere&at=$main" >"$T/res"42has "$T/res" "\"error\":\"$(printf %.7s "$main") isn't a revision of #1; reload the page and comment again\"\\} 400\$"43echo Nowhere | fails_with "^forge: $(printf %.7s "$main") isn't a pushed revision of #1; push it, or name the review by number\$" ssh_as ana comment dami/greet 1 --at "$main"44post comment "body=Nowhere&at=nope" >"$T/res"45has "$T/res" '"error":"comment: at is not a commit id"\} 400$'46post approve "at=$r2" >"$T/res"47has "$T/res" '"ok":true'48missing "$d/3"