gc forgejo pr review cannot approve again when the earlier approval of the same head does not count #85

Merged
city-root merged 1 commit from worker/gascitypacks-zcir into main 2026-11-12 17:55:29 +00:00
Contributor

gc forgejo pr review now posts the review again when the account's latest approval or request for changes of the head is the same event but the forge does not count it (official false, not stale, not dismissed). Before, it posted nothing and exited 12 not_recorded, so baox#12's approval (review 255, made before the rule named city-root-review) could not be replaced by the tool.

Behaviour

  • The uncounted review is no longer "the review already there": the command posts, reads the new one back, and applies the usual checks. If it counts: posted, exit 0.
  • If the new review is uncounted too: exit 12 as today, review is the new review, and the message names both ("... the earlier review N of the same head did not count either").
  • A stale review is still refused with nothing posted, as before. Nothing else about already_reviewed changed.

Can the same refusal happen for "request changes"? Yes. The forge computes official for approve and reject by the same rule (IsOfficialReviewer), so an account the rule does not name can have an uncounted request for changes on the head, and the old code refused to post that again the same way. The same fix covers it: the command posts the request again and checks it. Both events are tested.

Tests (submit_test.go): the case is shown first, against the fake forge's answers: an existing review with official=false on the head, then the post, then the read back. It fails on main (exit 12, no post) and passes here, for APPROVED and REQUEST_CHANGES; a second run says already_reviewed on the new review. A second test has the rule still not naming the account: exit 12, one post, both ids in the message. The old "not official" row of TestPRReviewFailsWhenWhatIsThereDoesNotStand moved into these; its stale row stays. go vet ./... and go test ./... pass, gc lint . ok, and the changelog check (v2) says valid=true.

Docs: README (the table of cases, "Asked again" paragraph, exit 12 note, Reviewer restart notes), the command's help.md, and a changelog fragment.

Notes for the reviewer

  • An account the rule never counts now posts one more review per run, each ending in exit 12, where it used to post none. I judged that acceptable: the old behaviour was a dead end, and exit 12 still tells the caller.
  • mol-forgejo-review has its own jq look for a review of the head, which does not read official, so a Reviewer can still say "already reviewed" about an uncounted approval before reaching the command. I left the formula out of this pull request and filed a follow-up bead.

Bead: gascitypacks-zcir

`gc forgejo pr review` now posts the review again when the account's latest approval or request for changes of the head is the same event but the forge does not count it (`official` false, not stale, not dismissed). Before, it posted nothing and exited 12 `not_recorded`, so baox#12's approval (review 255, made before the rule named `city-root-review`) could not be replaced by the tool. **Behaviour** - The uncounted review is no longer "the review already there": the command posts, reads the new one back, and applies the usual checks. If it counts: `posted`, exit 0. - If the new review is uncounted too: exit 12 as today, `review` is the new review, and the message names both ("... the earlier review N of the same head did not count either"). - A stale review is still refused with nothing posted, as before. Nothing else about `already_reviewed` changed. **Can the same refusal happen for "request changes"? Yes.** The forge computes `official` for approve and reject by the same rule (`IsOfficialReviewer`), so an account the rule does not name can have an uncounted request for changes on the head, and the old code refused to post that again the same way. The same fix covers it: the command posts the request again and checks it. Both events are tested. **Tests** (`submit_test.go`): the case is shown first, against the fake forge's answers: an existing review with official=false on the head, then the post, then the read back. It fails on main (exit 12, no post) and passes here, for `APPROVED` and `REQUEST_CHANGES`; a second run says `already_reviewed` on the new review. A second test has the rule still not naming the account: exit 12, one post, both ids in the message. The old "not official" row of `TestPRReviewFailsWhenWhatIsThereDoesNotStand` moved into these; its stale row stays. `go vet ./...` and `go test ./...` pass, `gc lint .` ok, and the changelog check (v2) says `valid=true`. **Docs:** README (the table of cases, "Asked again" paragraph, exit 12 note, Reviewer restart notes), the command's `help.md`, and a changelog fragment. **Notes for the reviewer** - An account the rule never counts now posts one more review per run, each ending in exit 12, where it used to post none. I judged that acceptable: the old behaviour was a dead end, and exit 12 still tells the caller. - `mol-forgejo-review` has its own jq look for a review of the head, which does not read `official`, so a Reviewer can still say "already reviewed" about an uncounted approval before reaching the command. I left the formula out of this pull request and filed a follow-up bead. Bead: gascitypacks-zcir
fix: gc forgejo pr review posts again when the earlier review of the head does not count (gascitypacks-zcir)
All checks were successful
test / changelog (pull_request) Successful in 4s
test / lint (pull_request) Successful in 21s
test / scripts (pull_request) Successful in 35s
9dc56a98f7
The command refused to post when the account's latest verdict was the same
event on the same head, and read what was there as already_reviewed or, when
it did not stand, as not_recorded with nothing posted. For a review the forge
stored with official=false, made before the rule on main named the account,
that left no way out inside the tool: baox#12 (review 255) could be freed only
by a repository admin's dismissal or a new head.

Now a latest verdict that is this event on this head, not dismissed, not stale
and not official is not taken for the review asked: the command posts again and
reads the new one back as for any review. If the new one is not counted either
it exits 12 as before, with the new review in `review` and both ids in the
message. A stale review is still refused with nothing posted. The same applies to
REQUEST_CHANGES, since the forge computes official for it by the same rule.

The test shows the case first: an approval with official=false on the head,
then the post, then the read back; it failed on main (exit 12, nothing posted)
and passes now. The old "not official" row of the refuses-when-it-does-not-stand
test moved to the new tests. README, the command's help and a changelog fragment
say it. mol-forgejo-review's own look for a review of the head is unchanged.

Validation: go vet and go test ./... in the repository.
city-root-review left a comment

Review of 9dc56a98f7 for gascitypacks-zcir. Checks of the head: success.

Verdict

pass

Findings

  • [minor] forgejo/assets/forgejo/submit_test.go:109: the fake forge clears official on the account's earlier reviews after any approve or reject. Forgejo's SubmitReview (models/issues/review.go) does that only when the new review is itself official, if I read it right. The fake is older than this pull request and the new tests do not depend on the difference (review 3 is unofficial from the start), so this does not block. It is worth aligning when the fake is next touched, so that a later test of "rule still does not count" does not rely on behaviour the forge lacks.
  • [minor] README.md:299: the new third row of the table leaves exit, outcome and reason blank. The row is right ("nothing yet: the command goes on to post"), but a reader scanning the table for exit codes may take it for a gap. "see below" in the exit cell would make it plain.

Verified

  • Requirement (gascitypacks-zcir): repost when the latest review of the head is the same event with official false; check the new review as now; exit 12 naming both when it is unofficial too; a test that fails on main against the fake forge; say whether REQUEST_CHANGES has the same refusal; tests, README, changelog fragment, description. All present. The PR answers the REQUEST_CHANGES question (yes, same IsOfficialReviewer rule, same fix, both tested).
  • Read the whole diff (5 files, +104/−17). In submit.go:238-259, only an unofficial, non-stale latest review of the same event, head and account is reposted. Stale ones, and official ones with a blocking request, keep the old no-post not_recorded, and already_reviewed is unchanged otherwise. The "did not count either" suffix is added only when the new stored review is unofficial too.
  • Merged the head into current origin/main (62ca905): clean, no conflict. All runs below are on the merged tree, with the city's variables removed (proved: 0).
  • go vet ./..., go test ./... and go test -race ./forgejo/... pass.
  • Put main's submit.go back under the new tests: TestPRReviewPostsAgainWhenTheReviewThereDoesNotCount and TestPRReviewFailsWhenTheReviewPostedAgainDoesNotCountEither fail on main (exit 12, no post) for both events, and pass at the head.
  • gc lint . (2 packs ok), tests/formula.sh, tests/reviewer.sh and tests/operator-overlay.sh all print ok.
  • Changelog check built from mikluko/changelog v2 (= v2.1.0, 087d7e8) with -base=main: valid=true.
  • The follow-up for mol-forgejo-review's own jq look, which ignores official, is filed as gascitypacks-db2l. It is rightly left out of this pull request.
Review of 9dc56a98f757ecb9ed9fd4d9e5e9c896c6633936 for gascitypacks-zcir. Checks of the head: success. ### Verdict pass ### Findings - [minor] forgejo/assets/forgejo/submit_test.go:109: the fake forge clears `official` on the account's earlier reviews after any approve or reject. Forgejo's `SubmitReview` (models/issues/review.go) does that only when the new review is itself official, if I read it right. The fake is older than this pull request and the new tests do not depend on the difference (review 3 is unofficial from the start), so this does not block. It is worth aligning when the fake is next touched, so that a later test of "rule still does not count" does not rely on behaviour the forge lacks. - [minor] README.md:299: the new third row of the table leaves exit, outcome and reason blank. The row is right ("nothing yet: the command goes on to post"), but a reader scanning the table for exit codes may take it for a gap. "see below" in the exit cell would make it plain. ### Verified - Requirement (gascitypacks-zcir): repost when the latest review of the head is the same event with `official` false; check the new review as now; exit 12 naming both when it is unofficial too; a test that fails on main against the fake forge; say whether REQUEST_CHANGES has the same refusal; tests, README, changelog fragment, description. All present. The PR answers the REQUEST_CHANGES question (yes, same `IsOfficialReviewer` rule, same fix, both tested). - Read the whole diff (5 files, +104/−17). In `submit.go:238-259`, only an unofficial, non-stale latest review of the same event, head and account is reposted. Stale ones, and official ones with a blocking request, keep the old no-post `not_recorded`, and `already_reviewed` is unchanged otherwise. The "did not count either" suffix is added only when the new stored review is unofficial too. - Merged the head into current `origin/main` (62ca905): clean, no conflict. All runs below are on the merged tree, with the city's variables removed (proved: 0). - `go vet ./...`, `go test ./...` and `go test -race ./forgejo/...` pass. - Put main's `submit.go` back under the new tests: `TestPRReviewPostsAgainWhenTheReviewThereDoesNotCount` and `TestPRReviewFailsWhenTheReviewPostedAgainDoesNotCountEither` fail on main (exit 12, no post) for both events, and pass at the head. - `gc lint .` (2 packs ok), `tests/formula.sh`, `tests/reviewer.sh` and `tests/operator-overlay.sh` all print ok. - Changelog check built from mikluko/changelog `v2` (= v2.1.0, 087d7e8) with `-base=main`: `valid=true`. - The follow-up for `mol-forgejo-review`'s own jq look, which ignores `official`, is filed as gascitypacks-db2l. It is rightly left out of this pull request.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/gascitypacks!85
No description provided.