github

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package github implements backend.Backend against the GitHub REST API.

Index

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 New

func New(owner, repo, token string, opts ...Option) *Client

New returns a Client for owner/repo, authenticated with token.

func (*Client) CommitURL

func (c *Client) CommitURL(sha string) string

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

func (c *Client) CompareURL(from, to string) string

CompareURL implements backend.Backend.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, tag string) error

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

func (c *Client) ResolvePR(ctx context.Context, sha string) (commit.PRReference, bool, error)

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

func (c *Client) UpsertDraft(ctx context.Context, req backend.UpsertDraftRequest) error

UpsertDraft implements backend.Backend.

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL overrides the API base URL — tests point this at an httptest server instead of the real api.github.com.

Jump to

Keyboard shortcuts

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