Documentation
¶
Index ¶
- Constants
- func Error(status int, format string, values ...any) error
- func FormatComments(comments []ReviewComment, includeResolved bool) string
- func Message(value string) *string
- func PatchContext(patch, side string, start, end int) (string, bool)
- func PatchDigest(patch FilePatch) string
- func Permanent(err error) bool
- func RemoteRepositoryKey(remote string) string
- func RemoteRepositoryName(remote, fallback string) string
- type Applicability
- type ChangedFile
- type CommentAnchor
- type CommentCarriedFrom
- type CommentPlacement
- type Commit
- type CommitRange
- type CommitSummary
- type ComparisonKind
- type DiagnosticError
- type DiffMode
- type FileContents
- type FilePatch
- type PatchReader
- type RepositoryDiff
- type RequestError
- type ReviewComment
- type ReviewFileOrigin
- type ReviewMark
- type ReviewOrigin
- type ScopeSummary
- type Source
- type Support
Constants ¶
const MaxCommits = 100
MaxCommits bounds the commits one observation captures: the newest of the branch's merge-base..HEAD range.
Variables ¶
This section is empty.
Functions ¶
func FormatComments ¶
func FormatComments(comments []ReviewComment, includeResolved bool) string
FormatComments exports comments using their computed placements. Unresolved exports include every open comment; stale and carried ones are tagged.
func PatchDigest ¶ added in v0.2.2
PatchDigest identifies a file's stored patch text so review marks carry between snapshots only while the reviewed change is identical.
func Permanent ¶ added in v0.2.1
Permanent reports whether retrying the same request cannot succeed: a client-class rejection other than timeout or rate limiting. Unclassified errors, timeouts, throttling and server failures are transient.
func RemoteRepositoryKey ¶ added in v0.2.1
RemoteRepositoryKey is the initial repository identity enrolled for a sanitized remote URL. Collectors and the server's GitHub integration share it, so pull requests group with checkouts cloned from the same URL.
func RemoteRepositoryName ¶
Types ¶
type Applicability ¶
type Applicability string
Applicability says where a stream comment applies in a viewed snapshot.
const ( Anchored Applicability = "anchored" Moved Applicability = "moved" Outdated Applicability = "outdated" Unchanged Applicability = "unchanged" OtherScope Applicability = "other-scope" Unknown Applicability = "unknown" )
func (Applicability) Inline ¶ added in v0.2.1
func (applicability Applicability) Inline() bool
Inline reports whether the comment renders on lines of the viewed snapshot.
func (Applicability) Stale ¶ added in v0.2.1
func (applicability Applicability) Stale() bool
Stale reports whether the comment was written against code that changed.
type ChangedFile ¶
type ChangedFile struct {
ID string `json:"id"`
Path string `json:"path"`
OldPath *string `json:"oldPath"`
Status string `json:"status"`
IndexStatus string `json:"indexStatus"`
WorktreeStatus string `json:"worktreeStatus"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Binary bool `json:"binary"`
Fingerprint string `json:"fingerprint"`
Recreated bool `json:"recreated,omitempty"`
}
func FileFor ¶ added in v0.2.1
func FileFor(path string, files []ChangedFile) (ChangedFile, bool)
FileFor finds a comment's file by path, or by a rename away from that path.
type CommentAnchor ¶ added in v0.2.1
func PatchAnchor ¶ added in v0.2.1
func PatchAnchor(patch, side string, start, end int) *CommentAnchor
PatchAnchor captures up to three contiguous same-side hunk lines before and after a selection, as content without diff prefixes.
type CommentCarriedFrom ¶ added in v0.2.1
type CommentPlacement ¶ added in v0.2.1
type CommentPlacement struct {
Applicability Applicability `json:"applicability"`
Side string `json:"side"`
Start int `json:"start"`
End int `json:"end"`
}
func Locate ¶ added in v0.2.1
func Locate(comment ReviewComment, viewed *RepositoryDiff, patch PatchReader) (CommentPlacement, error)
Locate places a stream comment in the viewed snapshot of a scope. Line comments re-anchor by content: the preserved code block must occur exactly once on the comment's side, preferring a match whose captured surrounding lines also match. Ambiguity never anchors.
type Commit ¶ added in v0.2.2
type Commit struct {
OID string `json:"oid"`
Parents []string `json:"parents"`
PatchID string `json:"patchId,omitempty"`
Subject string `json:"subject"`
Body string `json:"body"`
AuthorName string `json:"authorName"`
AuthoredAt int64 `json:"authoredAt"`
CommittedAt int64 `json:"committedAt"`
}
Commit is captured commit metadata. Merge commits have several parents and no captured diff.
type CommitRange ¶ added in v0.2.2
CommitRange counts captured commits and those omitted beyond MaxCommits.
type CommitSummary ¶ added in v0.2.2
type CommitSummary struct {
Commit
Merge bool `json:"merge"`
FileCount int `json:"fileCount"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
}
CommitSummary is a stored commit with its captured diff's totals.
type ComparisonKind ¶ added in v0.2.1
type ComparisonKind string
ComparisonKind describes captured endpoints independently of deployment or scope aliases.
const ( ComparisonCombined ComparisonKind = "combined" ComparisonUncommitted ComparisonKind = "uncommitted" ComparisonStaged ComparisonKind = "staged" ComparisonUnstaged ComparisonKind = "unstaged" ComparisonCommitted ComparisonKind = "committed" ComparisonPatch ComparisonKind = "patch" )
const ComparisonCommit ComparisonKind = "commit"
ComparisonCommit compares one commit with its first parent.
type DiagnosticError ¶ added in v0.2.4
DiagnosticError annotates a producer failure without changing its identity or retry classification. The report itself remains on the producer's machine.
func (*DiagnosticError) Error ¶ added in v0.2.4
func (failure *DiagnosticError) Error() string
func (*DiagnosticError) Unwrap ¶ added in v0.2.4
func (failure *DiagnosticError) Unwrap() error
type DiffMode ¶
type DiffMode string
const DiffCommit DiffMode = "commit"
DiffCommit names a captured commit's own diff. It is not a review scope: ParseDiffMode rejects it, so comments and reviewed marks never target it.
func ParseDiffMode ¶
type FileContents ¶
type FilePatch ¶
type FilePatch struct {
Patch string `json:"patch"`
Message *string `json:"message"`
Contents *FileContents `json:"contents,omitempty"`
}
type PatchReader ¶ added in v0.2.1
type PatchReader func(ChangedFile) (FilePatch, error)
PatchReader returns the viewed snapshot's stored patch for one of its files.
type RepositoryDiff ¶
type RepositoryDiff struct {
ID string `json:"id"`
VersionID string `json:"versionId"`
LocationID *string `json:"locationId"`
RepositoryID *string `json:"repositoryId"`
Source string `json:"source"`
Root string `json:"root"`
Name string `json:"name"`
Branch string `json:"branch"`
Head *string `json:"head"`
Mode DiffMode `json:"mode"`
ComparisonKind ComparisonKind `json:"comparisonKind,omitempty"`
Files []ChangedFile `json:"files"`
Revision string `json:"revision"`
}
type RequestError ¶
func (*RequestError) Error ¶
func (err *RequestError) Error() string
type ReviewComment ¶
type ReviewComment struct {
ID string `json:"id"`
DiffID string `json:"diffId"`
VersionID string `json:"versionId"`
Path string `json:"path"`
Scope DiffMode `json:"scope"`
Fingerprint string `json:"fingerprint"`
Target string `json:"target,omitempty"`
Side string `json:"side"`
Start int `json:"start"`
End int `json:"end"`
Code string `json:"code"`
Body string `json:"body"`
Status string `json:"status"`
CreatedAt float64 `json:"createdAt"`
Origin *ReviewOrigin `json:"origin,omitempty"`
// Anchor holds same-side content lines around the selection, captured at creation.
Anchor *CommentAnchor `json:"anchor,omitempty"`
// CarriedFrom records the original selection of a comment kept open at file level.
CarriedFrom *CommentCarriedFrom `json:"carriedFrom,omitempty"`
// Placement is computed for the viewed snapshot and never persisted.
Placement *CommentPlacement `json:"placement,omitempty"`
}
func (ReviewComment) Valid ¶
func (comment ReviewComment) Valid() bool
type ReviewFileOrigin ¶
type ReviewMark ¶
type ReviewOrigin ¶
type ScopeSummary ¶ added in v0.2.1
type ScopeSummary struct {
Scope DiffMode `json:"scope"`
ComparisonKind ComparisonKind `json:"comparisonKind"`
FileCount int `json:"fileCount"`
}