Documentation
¶
Index ¶
- Variables
- func Age(lastUpdated time.Time, now time.Time) string
- func ColourReset() string
- func SortByAge(repos []Repository)
- func SortByAgeDesc(repos []Repository)
- type Cache
- func (c *Cache) CacheDir() string
- func (c *Cache) Clear(org string) error
- func (c *Cache) ClearAll() error
- func (c *Cache) IsValid(org string) bool
- func (c *Cache) IsValidWithTime(org string, now time.Time) bool
- func (c *Cache) Load(org string) (OrganizationCache, error)
- func (c *Cache) LoadWithTime(org string, now time.Time) (OrganizationCache, error)
- func (c *Cache) Save(data OrganizationCache) error
- type Freshness
- type FreshnessSummary
- type GitHubClient
- type OrganizationCache
- type Repository
- type ScanOptions
- type ScanResult
- type Scanner
Constants ¶
This section is empty.
Variables ¶
var ( ErrCacheExpired = errors.New("cache expired") ErrCacheNotFound = errors.New("cache not found") )
Functions ¶
func SortByAge ¶
func SortByAge(repos []Repository)
SortByAge sorts repositories by last update time, oldest first.
func SortByAgeDesc ¶
func SortByAgeDesc(repos []Repository)
SortByAgeDesc sorts repositories by last update time, newest first.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides methods for storing and retrieving organization data.
func NewCacheWithDir ¶
NewCacheWithDir creates a Cache with a custom base directory (useful for testing).
func (*Cache) IsValidWithTime ¶
IsValidWithTime checks cache validity using a specific reference time.
func (*Cache) Load ¶
func (c *Cache) Load(org string) (OrganizationCache, error)
Load retrieves organization repository data from the cache. Returns ErrCacheNotFound if no cache exists, or ErrCacheExpired if cache is stale.
func (*Cache) LoadWithTime ¶
LoadWithTime retrieves organization data using a specific reference time (for testing).
func (*Cache) Save ¶
func (c *Cache) Save(data OrganizationCache) error
Save stores organization repository data to the cache.
type Freshness ¶
type Freshness string
Freshness represents the staleness level of a repository.
func CalculateFreshness ¶
CalculateFreshness determines the freshness level based on the last update time.
func ParseFreshness ¶
ParseFreshness converts a string to a Freshness value.
type FreshnessSummary ¶
FreshnessSummary contains counts of repositories by freshness level.
func CalculateSummary ¶
func CalculateSummary(repos []Repository, now time.Time) FreshnessSummary
CalculateSummary computes the freshness summary for a list of repositories.
type GitHubClient ¶
type GitHubClient interface {
FetchRepositories(org string) ([]Repository, error)
}
GitHubClient provides methods for fetching GitHub data.
func NewGitHubClient ¶
func NewGitHubClient() GitHubClient
NewGitHubClient creates a new GitHub client. If GITHUB_TOKEN is set, uses direct API calls; otherwise falls back to gh CLI.
type OrganizationCache ¶
type OrganizationCache struct {
Organization string `json:"organization"`
FetchedAt time.Time `json:"fetched_at"`
Repositories []Repository `json:"repositories"`
}
OrganizationCache holds cached repository data for an organization.
type Repository ¶
type Repository struct {
Name string `json:"name"`
FullName string `json:"full_name"`
LastUpdated time.Time `json:"last_updated"`
HTMLURL string `json:"html_url"`
}
Repository represents a GitHub repository with its last update timestamp.
func FilterByFreshness ¶
func FilterByFreshness(repos []Repository, freshness Freshness, now time.Time) []Repository
FilterByFreshness returns repositories matching the specified freshness level.
func GetTopStale ¶
func GetTopStale(repos []Repository, n int) []Repository
GetTopStale returns the n oldest repositories.
type ScanOptions ¶
type ScanOptions struct {
Refresh bool // Force refresh even if cache is valid
}
ScanOptions configures the scan behaviour.
type ScanResult ¶
type ScanResult struct {
Organization string
Repositories []Repository
FetchedAt time.Time
FromCache bool
}
ScanResult contains the results of scanning an organization.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner provides methods for scanning organizations.
func NewScanner ¶
NewScanner creates a new Scanner with the default GitHub client and cache.
func NewScannerWithDeps ¶
func NewScannerWithDeps(client GitHubClient, cache *Cache) *Scanner
NewScannerWithDeps creates a Scanner with custom dependencies (useful for testing).
func (*Scanner) Scan ¶
func (s *Scanner) Scan(org string, opts ScanOptions) (*ScanResult, error)
Scan retrieves repository data for an organization, using cache if available.