Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was missed
Issue #107 explicitly requested adding
CommitID stringtovcs.ReviewRequestso both platform adapters can thread the commit anchor through the abstraction layer. PR #112 only addedcommitIDas a direct parameter togitea.Client.PostReview(the low-level Gitea client), not to the sharedvcs.ReviewRequesttype.The current
vcs.ReviewRequestinvcs/types.go:As a result:
github.Client.PostReviewstill sourcesCommitIDonly fromreq.Comments[i].CommitID(comment-by-comment), not from a top-level field. If a review has no inline comments,commit_idis empty on the GitHub side too.gitea.Adapter.PostReviewhas no way to pass the commit anchor without this field.This was the core request in issue #107: "Add a
CommitID stringfield tovcs.ReviewRequestand pass it explicitly from the caller."Source
CommitID stringadded tovcs.ReviewRequestvcs/types.go(ReviewRequest struct)What needs to happen
CommitID string \json:"commit_id,omitempty"`tovcs.ReviewRequest`gitea.Adapter.PostReviewto passreq.CommitIDto the underlying clientgithub.Client.PostReviewto usereq.CommitIDas the primary commit anchor, falling back to comment-derived CommitID if empty and non-conflictingvcs.Client.PostReview(specificallycmd/review-bot/main.go) to populateReviewRequest.CommitIDwithevaluatedSHAReferences
Plan: Add CommitID to vcs.ReviewRequest (#115)
Problem
PR #112 refactored the review path to use the
vcs.ReviewRequestabstraction, but removed thecommitIDparameter fromgitea.Client.PostReviewwithout adding a correspondingCommitIDfield tovcs.ReviewRequest. This means:commitIDwas previously a direct parameter togitea.Client.PostReview(onorigin/main) but got dropped during the refactoring.CommitIDfromreq.Comments[i].CommitID— if a review has no inline comments, nocommit_idis sent to GitHub either.cmd/review-bot/main.go) setsCommitIDon each inline comment but doesn't set it at the review level.Constraints
origin/feature/github-support(that's wherevcs/package exists)Proposed Approach
4 changes, all minimal:
vcs/types.go— AddCommitID stringfield toReviewRequest:gitea/adapter.go— Passreq.CommitIDto the underlyinggitea.Client.PostReview. This requires adding thecommitIDparameter back togitea.Client.PostReview.gitea/client.go— Re-addcommitID stringparameter toPostReviewand include it in the JSON payload (matching origin/main's original signature).github/review.go— Usereq.CommitIDas primary commit anchor; fall back to comment-derived CommitID ifreq.CommitIDis empty. If both exist and conflict, return error.cmd/review-bot/main.go— SetReviewRequest.CommitID = evaluatedSHA(currentlypr.Head.SHA) when constructing the review request.State/Data Model
No new states.
CommitIDis a pass-through value from caller → adapter → API.Error Cases
req.CommitIDis empty: adapters behave as today (Gitea defaults to PR head, GitHub derives from comments or omits)req.CommitIDconflicts with a comment's CommitID (GitHub): returnErrConflictingCommitIDsreq.CommitIDset but no comments: both APIs accept review-level commit_id without commentsEdge Cases
req.CommitIDis the only source → sent to both APIsCommitIDmatchingreq.CommitID: no conflictCommitIDfromreq.CommitID(GitHub): errorTesting Strategy
github/review_test.go: Verifyreq.CommitIDis used as primary anchorgithub/review_test.go: Verify fallback to comment CommitID whenreq.CommitIDemptygithub/review_test.go: Verify conflict detection betweenreq.CommitIDand comment CommitIDgitea/adapter_test.go: Verifyreq.CommitIDis forwarded to underlying clientgitea/client_test.go: Verify commitID appears in JSON payloadCompletion Checklist
CommitID stringadded tovcs.ReviewRequestwith json tagcommit_id,omitempty?gitea.Client.PostReviewaccepts and forwardscommitIDparameter?gitea.Adapter.PostReviewpassesreq.CommitIDto underlying client?github.Client.PostReviewusesreq.CommitIDas primary, falls back to comment-derived?req.CommitID!= comment CommitID in GitHub adapter?cmd/review-bot/main.gosetsReviewRequest.CommitID = evaluatedSHA?Open Questions
commit_idfield at the review level (per Gitea docs). PR #112 removed it from the client; this fix adds it back. Straightforward.req.CommitIDoverride comment-level CommitIDs in GitHub, or should they be required to match? I'm going with "required to match (error on conflict)" since that's safest and matches existing behavior for comment-to-comment conflicts.