Files
review-bot/vcs/types.go
T
claw 2dedab1ad3
CI / test (pull_request) Successful in 18s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 41s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m20s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m52s
feat(#130): add VCS routing in cmd/review-bot via --vcs-type flag
- Add vcs_client.go with vcsClient interface, giteaClientVCSAdapter, githubClientVCSAdapter
- Add giteaExtendedClient interface for Gitea-specific operations (supersede, resolve, etc.)
- Add --vcs-type flag (gitea|github, default: gitea) with VCS_TYPE env var support
- Replace direct giteaClient usage with vcsClient interface in main.go
- Add verdictToVCSEvent() to map LLM verdict to vcs.ReviewEvent
- Gitea adapter translates vcs.ReviewEvent back to Gitea API format (APPROVE->APPROVED)
- Guard Gitea-specific ops (RequestReviewer, supersede, resolve) with type assertion
- Guard fetchPatterns GetAllFilesInPath with Gitea-only type assertion
- Replace reviewClientAdapter (giteaClientAdapter) for review.GiteaClient interface
- Update main_test.go to use reviewInfo/commitStatusInfo instead of gitea types
2026-05-14 13:53:56 -07:00

79 lines
2.3 KiB
Go

// Package vcs defines shared types used across VCS client implementations
// (gitea, github). Keeping them here prevents the client packages from
// importing each other or duplicating definitions.
package vcs
// ReviewEvent is the verdict submitted with a pull request review.
type ReviewEvent string
const (
// ReviewEventApprove approves the pull request.
ReviewEventApprove ReviewEvent = "APPROVE"
// ReviewEventRequestChanges requests changes before the PR can be merged.
ReviewEventRequestChanges ReviewEvent = "REQUEST_CHANGES"
// ReviewEventComment leaves a comment review without explicit approval or rejection.
ReviewEventComment ReviewEvent = "COMMENT"
)
// UserInfo holds the identity of a user.
type UserInfo struct {
Login string
}
// ReviewComment is a single inline comment attached to a pull request review.
type ReviewComment struct {
// Path is the file path the comment applies to.
Path string
// Position is the line position within the diff (1-indexed).
// GitHub and Gitea differ in how they compute position; callers must
// supply the correct value for the target VCS.
Position int
// Body is the text content of the comment.
Body string
// CommitID is the SHA of the commit the comment applies to.
// For GitHub, all comments within a single review must target the same commit.
CommitID string
}
// ReviewRequest is the payload for submitting a pull request review.
type ReviewRequest struct {
// Body is the top-level review comment body.
Body string
// Event is the review verdict.
Event ReviewEvent
// CommitID is the commit SHA that this review targets.
// When non-empty, the review is anchored to this commit.
// For GitHub, this is passed as commit_id in the review request.
// For Gitea, this is passed as the commitID parameter to PostReview.
CommitID string
// Comments are optional inline file-level comments.
Comments []ReviewComment
}
// Review represents a submitted pull request review.
type Review struct {
// ID is the provider-assigned review identifier.
ID int64
// Body is the top-level review comment body.
Body string
// User is the author of the review.
User UserInfo
// State is the canonical review state string.
// Values: APPROVE, REQUEST_CHANGES, COMMENT, DISMISSED, PENDING.
State string
// CommitID is the commit SHA the review was evaluated against.
CommitID string
}