publish

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommentTarget added in v0.5.0

func CommentTarget(target string) (int64, error)

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

func (p *Publisher) Conversation(ctx context.Context, ref pr.Ref) (Conversation, error)

Conversation reads ref's unresolved review threads and latest reviews through GraphQL reads.

func (*Publisher) Head added in v0.5.0

func (p *Publisher) Head(ctx context.Context, ref pr.Ref) (string, error)

Head is ref's head commit as GitHub has it now.

func (*Publisher) Place

func (p *Publisher) Place(context.Context, src.Draft) (src.Placed, error)

Place keeps a draft on its own pull request.

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, d src.Draft) (src.Evidence, error)

Publish posts d as its delivery says.

func (*Publisher) Validate

func (p *Publisher) Validate(ctx context.Context, d src.Draft) error

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.

func (*Publisher) Where

func (p *Publisher) Where(ctx context.Context, d src.Draft) (string, error)

Where names the pull request d posts on.

func (*Publisher) Within added in v0.5.0

func (p *Publisher) Within(ctx context.Context, ref pr.Ref, target string) (bool, error)

Within says whether target lies inside ref: ref itself, comment:<id> for one of its review comments, or thread:<id> for one of its review threads by node id. A target GitHub does not know is outside.

type REST

type REST interface {
	REST(ctx context.Context, r api.Request) (api.Response, error)
}

REST is GitHub's REST API.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL