Documentation
¶
Overview ¶
Package publish posts the GitHub plugin's approved drafts on their pull request: an issue comment, a review, a reply in a review thread, a thread's resolution or a request for reviews.
Index ¶
- func CommentTarget(target string) (int64, error)
- type Conversation
- type InlineComment
- type LatestReview
- type OpenThread
- type Publisher
- func (p *Publisher) Conversation(ctx context.Context, ref pr.Ref) (Conversation, error)
- func (p *Publisher) Head(ctx context.Context, ref pr.Ref) (string, error)
- func (p *Publisher) Place(context.Context, src.Draft) (src.Placed, error)
- func (p *Publisher) Publish(ctx context.Context, d src.Draft) (src.Evidence, error)
- func (p *Publisher) Validate(ctx context.Context, d src.Draft) error
- func (p *Publisher) Verify(ctx context.Context, d src.Draft, startedAt time.Time) (src.Evidence, bool, error)
- func (p *Publisher) Where(ctx context.Context, d src.Draft) (string, error)
- func (p *Publisher) Within(ctx context.Context, ref pr.Ref, target string) (bool, error)
- type REST
- type Review
- type ReviewRequest
- type ThreadComment
- type Threads
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommentTarget ¶ added in v0.5.0
CommentTarget is the review comment a target of the form comment:<id> names, by its REST id.
Types ¶
type Conversation ¶ added in v0.5.0
type Conversation struct {
Threads []OpenThread `json:"threads"`
Reviews []LatestReview `json:"latest_reviews"`
}
Conversation is what a pull request's review asks still: its unresolved review threads and each reviewer's latest review.
type InlineComment ¶ added in v0.5.0
type InlineComment struct {
Path string `json:"path"`
Line int `json:"line"`
Side string `json:"side,omitempty"`
StartLine int `json:"start_line,omitempty"`
StartSide string `json:"start_side,omitempty"`
Body string `json:"body"`
}
InlineComment is one of a review's inline comments, as GitHub takes it.
type LatestReview ¶ added in v0.5.0
type LatestReview struct {
Author string `json:"author"`
State string `json:"state"`
Commit string `json:"commit"`
SubmittedAt time.Time `json:"submitted_at"`
}
LatestReview is a reviewer's latest review.
type OpenThread ¶ added in v0.5.0
type OpenThread struct {
Path string `json:"path"`
Line int `json:"line,omitempty"`
IsResolved bool `json:"is_resolved"`
IsOutdated bool `json:"is_outdated"`
Comments []ThreadComment `json:"comments"`
}
OpenThread is an unresolved review thread; a comment's ID is the REST id a thread_reply or a resolve targets as comment:<id>.
type Publisher ¶
type Publisher struct {
GH REST
// Threads nil refuses a resolve.
Threads Threads
Viewer func(ctx context.Context) (string, error)
// People are the persons the unit's items name, for mentions of other
// providers.
People func(ctx context.Context, u sdk.Unit) ([]src.Person, error)
// Record keeps an event on the host.
Record func(ctx context.Context, ev src.Event) error
Now func() time.Time
Log func(format string, args ...any)
}
Publisher posts GitHub drafts on their pull request, by delivery.
func (*Publisher) Conversation ¶ added in v0.5.0
Conversation reads ref's unresolved review threads and latest reviews through GraphQL reads.
func (*Publisher) Validate ¶
Validate refuses a draft GitHub cannot take on the draft's own pull request as its delivery posts it.
func (*Publisher) Verify ¶
func (p *Publisher) Verify(ctx context.Context, d src.Draft, startedAt time.Time) (src.Evidence, bool, error)
Verify says whether d was posted at or after startedAt, as its delivery posts it.
type Review ¶ added in v0.5.0
type Review struct {
Event string `json:"event"`
Comments []InlineComment `json:"comments,omitempty"`
}
Review is a review draft's payload, which drafts/review/schema.json shapes.
func DecodeReview ¶ added in v0.5.0
func DecodeReview(raw json.RawMessage) (Review, error)
DecodeReview is a review draft's payload, refused when it does not fit the kind's schema.
type ReviewRequest ¶ added in v0.5.0
type ReviewRequest struct {
Reviewers []string `json:"reviewers"`
}
ReviewRequest is a request_review draft's payload, which drafts/request_review/schema.json shapes.
func DecodeReviewRequest ¶ added in v0.5.0
func DecodeReviewRequest(raw json.RawMessage) (ReviewRequest, error)
DecodeReviewRequest is a request_review draft's payload, refused when it does not fit the kind's schema.
type ThreadComment ¶ added in v0.5.0
type ThreadComment struct {
ID int64 `json:"id"`
Author string `json:"author"`
Body string `json:"body"`
At time.Time `json:"created_at"`
}
ThreadComment is a comment of a review thread.
type Threads ¶ added in v0.5.0
type Threads interface {
GraphQL(ctx context.Context, query string, vars map[string]any) (map[string]json.RawMessage, map[string]string, error)
ResolveReviewThread(ctx context.Context, threadID string) error
}
Threads reads a pull request's review threads and resolves one.