github

package
v0.2.26 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package github provides GitHub integration for querying PR status.

Package github provides GitHub integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchAllPRsForRepo

func FetchAllPRsForRepo(repoDir string) map[string]*PRInfo

FetchAllPRsForRepo fetches all open and recently merged PRs for a repo in a single API call. Returns a map of branch name -> PRInfo. This is much more efficient than fetching per-branch.

func IsNewerVersion

func IsNewerVersion(current, latest string) bool

IsNewerVersion returns true if latest is a newer version than current. Both should be semver strings, optionally prefixed with "v".

func MarshalPRInfo

func MarshalPRInfo(info *PRInfo) string

MarshalPRInfo converts a PRInfo to JSON string for database storage.

Types

type CheckState

type CheckState string

CheckState represents the state of CI checks.

const (
	CheckStatePending CheckState = "PENDING"
	CheckStatePassing CheckState = "SUCCESS"
	CheckStateFailing CheckState = "FAILURE"
	CheckStateNone    CheckState = ""
)

type LatestRelease

type LatestRelease struct {
	Version string // e.g. "v0.2.0"
	URL     string // release page URL
}

LatestRelease holds information about the latest GitHub release.

func FetchLatestRelease

func FetchLatestRelease() *LatestRelease

FetchLatestRelease queries the GitHub API for the latest release. Returns nil if the request fails or no release exists.

type PRCache

type PRCache struct {
	// contains filtered or unexported fields
}

PRCache caches PR information to avoid repeated API calls.

func NewPRCache

func NewPRCache() *PRCache

NewPRCache creates a new PR cache.

func (*PRCache) GetCachedPR

func (c *PRCache) GetCachedPR(repoDir, branchName string) *PRInfo

GetCachedPR returns cached PR info without fetching. Returns nil if not cached or expired.

func (*PRCache) GetPRForBranch

func (c *PRCache) GetPRForBranch(repoDir, branchName string) *PRInfo

GetPRForBranch queries GitHub for a PR associated with the given branch. Uses caching to avoid repeated API calls. Returns nil if no PR exists or gh CLI is not available.

func (*PRCache) InvalidateCache

func (c *PRCache) InvalidateCache(repoDir, branchName string)

InvalidateCache clears the cache for a specific branch.

func (*PRCache) UpdateCacheForRepo

func (c *PRCache) UpdateCacheForRepo(repoDir string, prsByBranch map[string]*PRInfo)

UpdateCacheForRepo updates the cache with batch-fetched PR data for a repo. This is more efficient than individual fetches.

type PRInfo

type PRInfo struct {
	Number     int        `json:"number"`
	URL        string     `json:"url"`
	State      PRState    `json:"state"`
	IsDraft    bool       `json:"isDraft"`
	Title      string     `json:"title"`
	CheckState CheckState `json:"checkState"`
	Mergeable  string     `json:"mergeable"` // "MERGEABLE", "CONFLICTING", "UNKNOWN"
	UpdatedAt  time.Time  `json:"updatedAt"`
	Additions  int        `json:"additions"` // Lines added
	Deletions  int        `json:"deletions"` // Lines deleted
}

PRInfo contains information about a pull request.

func UnmarshalPRInfo

func UnmarshalPRInfo(data string) *PRInfo

UnmarshalPRInfo converts a JSON string from database back to PRInfo.

func (*PRInfo) StatusDescription

func (p *PRInfo) StatusDescription() string

StatusDescription returns a human-readable description.

func (*PRInfo) StatusIcon

func (p *PRInfo) StatusIcon() string

StatusIcon returns a unicode icon representing the PR state.

type PRState

type PRState string

PRState represents the state of a pull request.

const (
	PRStateOpen   PRState = "OPEN"
	PRStateClosed PRState = "CLOSED"
	PRStateMerged PRState = "MERGED"
	PRStateDraft  PRState = "DRAFT"
)

Jump to

Keyboard shortcuts

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