package vcs // ReviewEvent is the event type for a pull request review action. // Adapters must translate these action constants to/from platform-native values. // For example, Gitea uses "APPROVED" as both action and state, while GitHub // uses "APPROVE" for the action and returns "approved" as the state. type ReviewEvent string const ( // ReviewEventApprove approves the pull request. ReviewEventApprove ReviewEvent = "APPROVE" // ReviewEventRequestChanges requests changes to the pull request. ReviewEventRequestChanges ReviewEvent = "REQUEST_CHANGES" // ReviewEventComment posts a review comment without approval or rejection. ReviewEventComment ReviewEvent = "COMMENT" ) // BaseRef identifies the target branch of a pull request. type BaseRef struct { Ref string `json:"ref"` } // HeadRef identifies the source branch and latest commit of a pull request. type HeadRef struct { SHA string `json:"sha"` Ref string `json:"ref"` } // UserInfo identifies a user by login name. type UserInfo struct { Login string `json:"login"` } // PullRequest holds relevant PR metadata. type PullRequest struct { Number int `json:"number"` Title string `json:"title"` Body string `json:"body"` Head HeadRef `json:"head"` Base BaseRef `json:"base"` } // ChangedFile represents a file modified in a PR. type ChangedFile struct { Filename string `json:"filename"` Status string `json:"status"` Patch string `json:"patch"` } // ContentEntry represents a file or directory entry from the contents API. type ContentEntry struct { Name string `json:"name"` Path string `json:"path"` Type string `json:"type"` // "file" or "dir" } // CommitStatus represents a single CI status entry for a commit. type CommitStatus struct { Status string `json:"status"` Context string `json:"context"` Description string `json:"description"` TargetURL string `json:"target_url"` } // Review represents a pull request review. type Review struct { ID int64 `json:"id"` Body string `json:"body"` User UserInfo `json:"user"` State string `json:"state"` Stale bool `json:"stale"` CommitID string `json:"commit_id"` } // ReviewComment represents an inline comment in a review. // All adapters use GitHub diff-position convention: // - Position is a 1-indexed offset from the @@ hunk line in the unified diff. // - CommitID identifies the commit the comment is anchored to. // It is optional; omit (empty string) for review-level comments that are // not attached to a specific commit. // // Adapters are responsible for translating to/from platform-native formats // (e.g. Gitea uses line numbers; GitHub uses diff positions natively). type ReviewComment struct { Path string `json:"path"` Position int `json:"position"` // diff-position: 1-indexed offset from @@ hunk line CommitID string `json:"commit_id"` Body string `json:"body"` } // ReviewRequest is the payload for posting a review. type ReviewRequest struct { // Body is the top-level review comment. Body string `json:"body"` // Event is the review action (approve, request changes, or comment). Event ReviewEvent `json:"event"` // CommitID anchors the review to a specific commit SHA. // If empty, the platform defaults to the current PR head. // Adapters use this as the primary commit anchor for the review submission. CommitID string `json:"commit_id,omitempty"` Comments []ReviewComment `json:"comments,omitempty"` }