Documentation
¶
Overview ¶
Package ghcomment keeps one relgap comment per report kind on a GitHub pull request, edited in place and left alone when its content hasn't changed.
Index ¶
Constants ¶
const DefaultAPIURL = "https://api.github.com"
DefaultAPIURL is the GitHub REST API on github.com.
const Scope = "pull-request"
Scope is the marker scope of a pull request comment, which covers the whole report.
Variables ¶
var ErrAuth = errors.New("authentication failed")
ErrAuth is wrapped when GitHub refuses the token.
var ErrConfig = errors.New("pull request comment not configured")
ErrConfig is wrapped when the repository, the pull request or the token is missing.
Functions ¶
func PullRequestFromEvent ¶
PullRequestFromEvent reads the pull request number from a GitHub Actions event file. It knows pull_request, pull_request_target and issue_comment events on a pull request.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client edits the comments of one pull request.
func New ¶
New checks cfg and returns a client. Pass an httpx client: it retries reads and never resends a POST after a server error.
func (*Client) Publish ¶
Publish creates, edits or leaves the comment for p.Kind. A report with nothing open turns an existing comment into "Nothing to report" and creates none.
type Config ¶
type Config struct {
Repo string // owner/name
PullRequest int
APIURL string // DefaultAPIURL when empty
Token string
DryRun bool // read with GET only and write nothing
MaxChars int // the longest comment; render.DefaultMDMaxChars when 0
}
Config says which pull request to comment on.
type Marker ¶
type Marker struct {
Kind string `json:"kind"`
Scope string `json:"scope"`
Hash string `json:"hash"`
}
Marker is the hidden first line of a comment. Kind and Scope find the comment again; Hash says whether its content changed.
func ParseMarker ¶
ParseMarker finds the marker in a comment body.
type Post ¶
type Post struct {
Kind string // one comment per kind, such as drift
Title string // the comment's heading
Body string // Markdown under the heading, cut to fit when too long
Open bool // false when the report found nothing: the comment becomes "Nothing to report"
Hint string // ends the truncation footer, such as "Run relgap drift --format json."
}
Post is one report to publish.