prcache

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package prcache provides PR status caching stored in ~/.wt/prs.json. PRs are stored independently of worktree entries, keyed by folder name, allowing PR info to be cached before worktrees are created.

Index

Constants

View Source
const CacheMaxAge = 24 * time.Hour

CacheMaxAge is the maximum age of cached PR info before it's considered stale

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns the path to the PR cache file

Types

type Cache

type Cache struct {
	PRs map[string]*PRInfo `json:"prs"`
	// contains filtered or unexported fields
}

Cache stores PR info keyed by folder name

func Load

func Load() *Cache

Load loads the PR cache from disk. Returns an empty cache if the file is missing or corrupted.

func New added in v0.15.0

func New() *Cache

New returns an empty, initialized cache.

func (*Cache) Delete

func (c *Cache) Delete(folder string)

Delete removes PR info for a folder

func (*Cache) Get

func (c *Cache) Get(folder string) *PRInfo

Get returns PR info for a folder, or nil if not found

func (*Cache) Reset

func (c *Cache) Reset()

Reset clears all cached data

func (*Cache) Save

func (c *Cache) Save() error

Save saves the PR cache to disk atomically

func (*Cache) SaveIfDirty added in v0.17.0

func (c *Cache) SaveIfDirty() error

SaveIfDirty saves the cache to disk only if it has been modified. Resets the dirty flag after a successful save.

func (*Cache) Set

func (c *Cache) Set(folder string, pr *PRInfo)

Set stores PR info for a folder

type PRInfo

type PRInfo struct {
	Number       int       `json:"number"`
	State        string    `json:"state"`    // Normalized: OPEN, MERGED, CLOSED
	IsDraft      bool      `json:"is_draft"` // true if PR is a draft
	URL          string    `json:"url"`
	Author       string    `json:"author"`        // username/login
	CommentCount int       `json:"comment_count"` // number of comments
	HasReviews   bool      `json:"has_reviews"`   // any reviews submitted
	IsApproved   bool      `json:"is_approved"`   // approved status
	CachedAt     time.Time `json:"cached_at"`
	Fetched      bool      `json:"fetched"` // true = API was queried (distinguishes "not fetched" from "no PR")
}

PRInfo represents pull request information

func FromForge added in v0.15.0

func FromForge(pr *forge.PRInfo) *PRInfo

FromForge converts a forge.PRInfo to a prcache.PRInfo. Returns nil if pr is nil.

func (*PRInfo) IsStale

func (p *PRInfo) IsStale() bool

IsStale returns true if the cache entry is older than CacheMaxAge

Jump to

Keyboard shortcuts

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