github

package
v0.16.397 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 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 github reads issues and pull requests from GitHub (or GitHub Enterprise) for the page: an issue as a task card and tab, an issue or a pull request link as a chip. The token stays on the machine.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound: no such issue, or the token cannot see it.

View Source
var ErrUnavailable = errors.New("unavailable")

ErrUnavailable: GitHub did not answer, or refused (rate limit, bad token).

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Author string `json:"author"`
	At     *int64 `json:"at"`
	Text   string `json:"text"`
}

Comment is one comment of an issue.

type Config

type Config struct {
	// API is the REST API root: https://api.github.com, or https://<host>/api/v3 for GitHub Enterprise.
	API string
	// Web is the host of the issue and pull request pages: github.com, or the Enterprise host.
	Web string
	// Token is a token with read access to the repositories; public repositories work without one (rate limited).
	Token string
	// Repos are the repositories whose issues the page may show: "owner/repo" or "owner/*"; empty allows any.
	Repos []string
	// Client calls the API; nil is a client with a 10 s timeout.
	Client *http.Client
}

Config names the GitHub the runtime reads.

func FromEnv

func FromEnv(getenv func(string) string) Config

FromEnv reads RUNTIME_GITHUB_API, RUNTIME_GITHUB_HOST, RUNTIME_GITHUB_TOKEN and RUNTIME_GITHUB_REPOS.

func (Config) Allowed

func (c Config) Allowed(r Ref) bool

Allowed says whether the page may read this repository.

func (Config) LinkMeta

func (c Config) LinkMeta(ctx context.Context, r Ref) (any, error)

LinkMeta is the chip of an issue or pull request link.

func (Config) ParseURL

func (c Config) ParseURL(raw string) (Ref, bool)

ParseURL reads https://<web>/owner/repo/issues/12 or /pull/12.

func (Config) Task

func (c Config) Task(ctx context.Context, r Ref) (Task, error)

Task is one issue (or pull request) with its last comments.

type IssueMeta

type IssueMeta struct {
	Kind     string  `json:"kind"`
	Key      string  `json:"key"`
	Title    string  `json:"title"`
	State    *string `json:"state"`
	Resolved bool    `json:"resolved"`
	Assignee *Person `json:"assignee"`
	Type     *string `json:"type"`
}

IssueMeta is an issue link's chip.

type Person

type Person struct {
	Name   string  `json:"name"`
	Avatar *string `json:"avatar"`
}

Person is who an issue is assigned to.

type PullMeta

type PullMeta struct {
	Kind    string `json:"kind"`
	IID     int    `json:"iid"`
	Title   string `json:"title"`
	State   string `json:"state"`
	Project string `json:"project"`
	Draft   bool   `json:"draft"`
}

PullMeta is a pull request link's chip, in the page's merge request shape.

type Ref

type Ref struct {
	Owner, Repo string
	Number      int
	// Pull is set for a pull request link (an issue key may name either).
	Pull bool
}

Ref is one issue or pull request.

func ParseKey

func ParseKey(key string) (Ref, bool)

ParseKey reads owner/repo#12.

func (Ref) Key

func (r Ref) Key() string

Key is the ref as the page names it: owner/repo#12.

type Task

type Task struct {
	Key         string     `json:"key"`
	Title       string     `json:"title"`
	Project     *string    `json:"project"`
	Type        *string    `json:"type"`
	State       *string    `json:"state"`
	Priority    *string    `json:"priority"`
	Resolved    bool       `json:"resolved"`
	Assignee    *Person    `json:"assignee"`
	Parent      *struct{}  `json:"parent"`
	Children    []struct{} `json:"children"`
	Description string     `json:"description"`
	Comments    []Comment  `json:"comments"`
	Updated     *int64     `json:"updated"`
	URL         string     `json:"url"`
	Provider    string     `json:"provider"`
}

Task is an issue in the page's task shape (the same one the YouTrack tracker answers with).

Jump to

Keyboard shortcuts

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