fetch

package
v0.0.0-...-aa0a1d3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2017 License: Apache-2.0 Imports: 16 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear(c *Context) error

Clear clears all cache entries for the repository specified in the fetch context.

func QueryAll

func QueryAll(c *Context) error

QueryAll recursively descends into GitHub API endpoints, starting with the list of stargazers for the repo.

func QueryContributions

func QueryContributions(c *Context, sg []*Stargazer, rs map[string]*Repo) error

QueryContributions queries all contributions to subscribed repos for each stargazer.

func QueryFollowers

func QueryFollowers(c *Context, sg []*Stargazer) error

QueryFollowers queries each stargazers list of followers.

func QueryStarred

func QueryStarred(c *Context, sg []*Stargazer, rs map[string]*Repo) error

QueryStarred queries all starred repos for each stargazer.

func QueryStatistics

func QueryStatistics(c *Context, r *Repo, authors map[string]struct{}) error

QueryStatistics queries contributor stats for the specified repo.

func QuerySubscribed

func QuerySubscribed(c *Context, sg []*Stargazer, rs map[string]*Repo) error

QuerySubscribed queries all subscribed repos for each stargazer.

func QueryUserInfo

func QueryUserInfo(c *Context, sg []*Stargazer) error

QueryUserInfo queries user info for each stargazer.

func SaveState

func SaveState(c *Context, sg []*Stargazer, rs map[string]*Repo) error

SaveState writes all queried stargazer and repo data.

Types

type Context

type Context struct {
	Repo     string // Repository (:owner/:repo)
	Token    string // Access token
	CacheDir string // Cache directory
	// contains filtered or unexported fields
}

Context holds config information used to query GitHub.

type Contribution

type Contribution struct {
	ID        int    `json:"id"`
	Login     string `json:"login"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Commits   int    `json:"commits"`
}

type Contributor

type Contributor struct {
	Author User   `json:"author"`
	Total  int    `json:"total"`
	Weeks  []Week `json:"weeks"`
}

type Repo

type Repo struct {
	ID              int    `json:"id"`
	Name            string `json:"name"`
	FullName        string `json:"full_name"`
	Private         bool   `json:"private"`
	HtmlURL         string `json:"html_url"`
	Fork            bool   `json:"fork"`
	URL             string `json:"url"`
	CreatedAt       string `json:"created_at"`
	UpdatedAt       string `json:"updated_at"`
	PushedAt        string `json:"pushed_at"`
	Homepage        string `json:"homepage"`
	Size            int    `json:"size"`
	StargazersCount int    `json:"stargazers_count"`
	WatchersCount   int    `json:"watchers_count"`
	Language        string `json:"language"`
	HasIssues       bool   `json:"has_issues"`
	HasDownloads    bool   `json:"has_downloads"`
	HasWiki         bool   `json:"has_wiki"`
	HasPages        bool   `json:"has_pages"`
	ForksCount      int    `json:"forks_count"`
	Forks           int    `json:"forks"`
	OpenIssues      int    `json:"open_issues"`
	Watchers        int    `json:"watchers"`
	DefaultBranch   string `json:"default_branch"`

	// Contributions map from user login to contributor statistics.
	Statistics map[string]*Contribution `json:"statistics"`
}

func (*Repo) TotalCommits

func (r *Repo) TotalCommits() (int, int, int)

TotalCommits returns the total commits as well as additions and deletions.

type Stargazer

type Stargazer struct {
	User      `json:"user"`
	StarredAt string `json:"starred_at"`

	Followers  []*User  `json:"follower_list"`
	Starred    []string `json:"starred"`    // Slice of repos by full name
	Subscribed []string `json:"subscribed"` // Slice of repos by full name

	// Contributions to subscribed repos (by repo FullName).
	Contributions map[string]*Contribution `json:"contributions"`
}

Stargazer holds all information and further query URLs for a stargazer.

func LoadState

func LoadState(c *Context) ([]*Stargazer, map[string]*Repo, error)

LoadState reads previously saved queried stargazer and repo data.

func QueryStargazers

func QueryStargazers(c *Context) ([]*Stargazer, error)

QueryStargazers queries the repo's stargazers API endpoint. Returns the complete slice of stargazers.

func (*Stargazer) Age

func (s *Stargazer) Age() int64

Age returns the age (time from current time to created at timestamp) of this stargazer in seconds.

func (*Stargazer) TotalCommits

func (s *Stargazer) TotalCommits() (int, int, int)

TotalCommits returns the total commits as well as additions and deletions, ranged over all tracked contributions.

type User

type User struct {
	Login            string `json:"login"`
	ID               int    `json:"id"`
	AvatarURL        string `json:"avatar_url"`
	GravatarID       string `json:"gravatar_id"`
	URL              string `json:"url"`
	HtmlURL          string `json:"html_url"`
	FollowersURL     string `json:"followers_url"`
	FollowingURL     string `json:"following_url"`
	StarredURL       string `json:"starred_url"`
	SubscriptionsURL string `json:"subscriptions_url"`
	Type             string `json:"type"`
	SiteAdmin        bool   `json:"site_admin"`
	Name             string `json:"name"`
	Company          string `json:"company"`
	Blog             string `json:"blog"`
	Location         string `json:"location"`
	Email            string `json:"email"`
	Hireable         bool   `json:"hireable"`
	Bio              string `json:"bio"`
	PublicRepos      int    `json:"public_repos"`
	PublicGists      int    `json:"public_gists"`
	Followers        int    `json:"followers"`
	Following        int    `json:"following"`
	CreatedAt        string `json:"created_at"`
	UpdatedAt        string `json:"updated_at"`
}

type Week

type Week struct {
	Timestamp int `json:"w"`
	Additions int `json:"a"`
	Deletions int `json:"d"`
	Commits   int `json:"c"`
}

Jump to

Keyboard shortcuts

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