github

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnrichPushEvent

func EnrichPushEvent(ev *Event)

EnrichPushEvent fetches compare stats and populates the event's detail cache.

Types

type Actor

type Actor struct {
	Login string `json:"login"`
}

type Comment

type Comment struct {
	Body string `json:"body"`
}

type Commit

type Commit struct {
	SHA     string `json:"sha"`
	Message string `json:"message"`
}

type CompareResult

type CompareResult struct {
	TotalCommits int `json:"total_commits"`
	Files        []struct {
		Filename  string `json:"filename"`
		Additions int    `json:"additions"`
		Deletions int    `json:"deletions"`
		Changes   int    `json:"changes"`
	} `json:"files"`
}

CompareResult holds diff stats from the compare API.

func FetchCompare

func FetchCompare(repo, base, head string) (*CompareResult, error)

FetchCompare gets diff stats between two commits.

type Event

type Event struct {
	ID          string         `json:"id"`
	Type        string         `json:"type"`
	Actor       Actor          `json:"actor"`
	Repo        Repo           `json:"repo"`
	Payload     Payload        `json:"payload"`
	CreatedAt   time.Time      `json:"created_at"`
	CompareData *CompareResult `json:"-"`
}

func (*Event) Detail

func (e *Event) Detail() string

Detail returns a human-readable description of the event payload.

func (*Event) Label

func (e *Event) Label() string

Label returns a short human-readable label for an event type.

func (*Event) ShortRepo

func (e *Event) ShortRepo() string

ShortRepo returns just the repo name without the owner prefix.

func (*Event) URL added in v0.2.0

func (e *Event) URL() string

URL returns a GitHub URL for the event, if applicable.

type FetchResult added in v0.2.6

type FetchResult struct {
	Events      []Event
	NotModified bool // true if 304 — data unchanged, didn't cost a rate limit point
	RateRemain  int  // parsed from X-RateLimit-Remaining header
	RateLimit   int  // parsed from X-RateLimit-Limit header
}

FetchResult holds the outcome of an ETag-aware fetch.

func FetchEvents

func FetchEvents(repo string, limit int, page int) (*FetchResult, error)

FetchEvents fetches recent events for a repo using the gh CLI with ETag support. page is 1-indexed; each page returns up to 30 events from the API. When the server returns 304 Not Modified, NotModified is true and Events is nil.

type Issue

type Issue struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
}

type Payload

type Payload struct {
	Action      string       `json:"action,omitempty"`
	Ref         string       `json:"ref,omitempty"`
	RefType     string       `json:"ref_type,omitempty"`
	Size        int          `json:"size,omitempty"`
	Before      string       `json:"before,omitempty"`
	Head        string       `json:"head,omitempty"`
	Commits     []Commit     `json:"commits,omitempty"`
	PullRequest *PullRequest `json:"pull_request,omitempty"`
	Issue       *Issue       `json:"issue,omitempty"`
	Comment     *Comment     `json:"comment,omitempty"`
	Release     *Release     `json:"release,omitempty"`
}

type PullRequest

type PullRequest struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	State  string `json:"state"`
}

type RateLimit added in v0.2.5

type RateLimit struct {
	Remaining int
	Limit     int
}

RateLimit holds GitHub API rate limit info.

func FetchRateLimit added in v0.2.5

func FetchRateLimit() (*RateLimit, error)

FetchRateLimit queries the GitHub API rate limit.

type Release

type Release struct {
	TagName string `json:"tag_name"`
	Name    string `json:"name"`
}

type Repo

type Repo struct {
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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