feat(#130): add vcs package with shared review types
This commit is contained in:
@@ -0,0 +1,72 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user