Documentation ¶
Index ¶
- Constants
- type KV
- type Star
- type StarManager
- func (s *StarManager) Cleanup(age int, archived bool) error
- func (s *StarManager) ClearCache() error
- func (s *StarManager) GetStars(count int, language, topic string, random bool) ([]*Star, error)
- func (s *StarManager) GetTopics() []KV
- func (s *StarManager) RemoveStar(star *Star, wg *sync.WaitGroup) (bool, error)
- func (s *StarManager) SaveAllStars(maxConcurrency int) error
- func (s *StarManager) SaveIfEmpty(concurrency int) error
- func (s *StarManager) SaveStarredPage(pageno int, responses chan *github.Response) chan error
- func (s *StarManager) SaveStarredRepository(star *github.StarredRepository, wg *sync.WaitGroup) error
- func (s *StarManager) StarRepositoriesFromOrg(org string, notOlderThanMonths, maxConcurrency int) error
- func (s *StarManager) StarRepositoriesFromURLs(urls []*url.URL, notOlderThanMonths, maxConcurrency int) (int, error)
- func (s *StarManager) StarRepository(owner, repo string) error
Constants ¶
const ( // GitHubHost - the main public GitHub GitHubHost string = "github.com" // GitHubAPIHost - the GitHub API host GitHubAPIHost string = "api." + GitHubHost // CachePath - the path to the cache db file CachePath string = ".cache" // CacheFile - the filename of the db cache CacheFile string = "stars.db" // PageSize - the default response page size (GitHub maximum is 100 so we // use that) PageSize int = 100 // DefaultConcurrency limits how many goroutines to run during network I/O // operations. DefaultConcurrency int = 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KV ¶ added in v0.2.0
KV is a generic struct that maintains a string key - int value pair ( :( )
type Star ¶
type Star struct { // Archives indicates whether the GitHub Repository has been archived Archived bool `storm:"index"` // Description holds the repository description (can be emppty) Description string `storm:"index"` // Language is the dominant programming language in the repository. // The official list of all recognized programming languages can be found // here: // https://github.com/github/linguist/blob/master/lib/linguist/languages.yml Language string `storm:"index"` // PushedAt represents the timestamp of the last (git) push to this // repository PushedAt time.Time `storm:"index"` // Stargazers is the number of users who have starred this repository Stargazers int // StarredAt represents the timestamp of when the current user starred this // repository. StarredAt time.Time `storm:"index"` // Topics are the tags/labels for the repository. Topics []string `storm:"index"` // URL is the full web URL of the repository (html_url field in the GitHub // API) URL string `storm:"id,index,unique"` }
Star represents the starred repository that is saved locally
type StarManager ¶
type StarManager struct {
// contains filtered or unexported fields
}
StarManager is the central object used to manage stars for a GitHub account
func New ¶
func New(logLevel log.Level) (*StarManager, error)
New constructs a new StarManager object. This method reads authentication configuration from the user's ~/.netrc file for the GitHub API host.
func (*StarManager) Cleanup ¶ added in v0.3.5
func (s *StarManager) Cleanup(age int, archived bool) error
Cleanup removes stars older than a specified time in months, optionally unstarring archived repositories as well
func (*StarManager) ClearCache ¶
func (s *StarManager) ClearCache() error
ClearCache resets the filesystem-local cache database file.
func (*StarManager) GetStars ¶ added in v0.6.17
GetStars returns repositories given a project count to return, and an optional language and topic to filter by. It can also randomize the results.
func (*StarManager) GetTopics ¶
func (s *StarManager) GetTopics() []KV
GetTopics returns topics for a repository, otherwise if no repository is passed, returns a list of all topics
func (*StarManager) RemoveStar ¶
RemoveStar unstars the repository on Github and removes the star from the local cache.
func (*StarManager) SaveAllStars ¶
func (s *StarManager) SaveAllStars(maxConcurrency int) error
SaveAllStars saves all of the user's starred repositories
func (*StarManager) SaveIfEmpty ¶
func (s *StarManager) SaveIfEmpty(concurrency int) error
SaveIfEmpty saves all stars if the local cache is empty
func (*StarManager) SaveStarredPage ¶
func (s *StarManager) SaveStarredPage( pageno int, responses chan *github.Response, ) chan error
SaveStarredPage saves an entire page of starred repositories concurrently, optionally sending server responses to a channel if it is provided.
func (*StarManager) SaveStarredRepository ¶
func (s *StarManager) SaveStarredRepository( star *github.StarredRepository, wg *sync.WaitGroup, ) error
SaveStarredRepository saves a single starred repository to the local cache.
func (*StarManager) StarRepositoriesFromOrg ¶ added in v0.6.17
func (s *StarManager) StarRepositoriesFromOrg( org string, notOlderThanMonths, maxConcurrency int, ) error
StarRepositoriesFromOrg stars a given org's repositories, given that they are not archived and are recently pushed to.
func (*StarManager) StarRepositoriesFromURLs ¶ added in v0.6.17
func (s *StarManager) StarRepositoriesFromURLs( urls []*url.URL, notOlderThanMonths, maxConcurrency int, ) (int, error)
StarRepositoriesFromURLs stars each repository in the given slice of repository URLs
func (*StarManager) StarRepository ¶ added in v0.6.17
func (s *StarManager) StarRepository(owner, repo string) error
StarRepository stars a given repository by owner and repository name