Documentation
¶
Overview ¶
Package github implements backend.Backend against the GitHub REST API.
Index ¶
- type Client
- func (c *Client) CommitURL(sha string) string
- func (c *Client) CompareURL(from, to string) string
- func (c *Client) Publish(ctx context.Context, tag string) error
- func (c *Client) ResolveAuthor(ctx context.Context, sha string) (backend.AuthorReference, bool, error)
- func (c *Client) ResolvePR(ctx context.Context, sha string) (commit.PRReference, bool, error)
- func (c *Client) UpsertDraft(ctx context.Context, req backend.UpsertDraftRequest) error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements backend.Backend against the GitHub REST API.
func (*Client) CommitURL ¶
CommitURL implements backend.Backend. GitHub's web UI is always github.com regardless of API base URL (only api.github.com is supported — no Enterprise base-URL override exists for this adapter).
func (*Client) CompareURL ¶ added in v0.2.0
CompareURL implements backend.Backend.
func (*Client) Publish ¶
Publish implements backend.Backend. It flips the draft release matching tag to published. GitHub creates the underlying tag at this point (drafts have none yet), pointed at target_commitish — left unset here, so it defaults to the repository's default branch HEAD at publish time, exactly what the caller expects "publish" to mean.
This must be two separate PATCH requests, not one combined payload — confirmed against the live API (see brpaz/draftsman's own v0.2.0 release). A draft's stored tag_name is GitHub's own "untagged-<hash>" placeholder (see findReleaseByTag) until a real tag exists; sending draft:false and tag_name together in one request still creates the tag under the placeholder, silently ignoring the resupplied tag_name for that transaction. Setting tag_name first, in its own request while still a draft, then flipping draft:false in a second request, produces the correct tag every time.
func (*Client) ResolveAuthor ¶
func (c *Client) ResolveAuthor(ctx context.Context, sha string) (backend.AuthorReference, bool, error)
ResolveAuthor implements backend.Backend using GitHub's "get a commit" endpoint, whose "author" field is the linked GitHub account for the commit's git author email — null when that email isn't tied to any account, in which case ok is false and callers fall back to the plain git author name (ADR-0001).
func (*Client) ResolvePR ¶
ResolvePR implements backend.Backend using GitHub's "list pull requests associated with a commit" endpoint — reliable on GitHub (unlike Gitea, which has no equivalent, or Forgejo, whose equivalent is unreliable; see ADR-0001, where those adapters' ResolvePR always returns ok=false).
func (*Client) UpsertDraft ¶
UpsertDraft implements backend.Backend.