gh

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IssueCommentEvent is the type returned when the user comments on an issue.
	IssueCommentEvent = "IssueCommentEvent"

	// PushEvent is the type when a user pushes code.
	PushEvent = "PushEvent"

	// WatchEvent is the type of event when a user watches a repo.
	WatchEvent = "WatchEvent"
)

Variables

View Source
var (
	// ErrNotOK is returned for 404s.
	ErrNotOK = fmt.Errorf("gh: server responded with a non-200")
)

Functions

func Init

func Init() error

Init will initialize Github api keys.

func ToWebURL added in v1.0.5

func ToWebURL(s string) string

ToWebURL will attempt to convert an API URL to a web-friendly URL.

Types

type Commit

type Commit struct {
	SHA string `json:"sha"`

	Payload struct {
		Message string `json:"message"`

		Author struct {
			Name  string `json:"name"`
			Email string `json:"email"`
			Date  string `json:"date"`
		} `json:"author"`

		Committer struct {
			Name  string `json:"name"`
			Email string `json:"email"`
			Date  string `json:"date"`
		} `json:"committer"`
	} `json:"commit"`

	Author    User `json:"author"`
	Committer User `json:"committer"`

	Parents []struct {
		SHA string `json:"sha"`
	} `json:"parents"`

	CreatedAt string `json:"created_at"`
}

Commit is a code change within a repository.

func (Commit) Created

func (c Commit) Created() (time.Time, error)

Created returns a time.Time for created_at.

type Event

type Event struct {
	ID   string `json:"id"`
	Type string `json:"type"`

	Repo struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
		URL  string `json:"url"`
	}

	Payload struct {
		Action string `json:"action"`

		Commits []struct {
			URL string `json:"url"`

			Author struct {
				Email string `json:"email"`
				Name  string `json:"name"`
			} `json:"author"`

			Message string `json:"message"`
		} `json:"commits"`

		Issue struct {
			Title string `json:"title"`
			URL   string `json:"url"`
			Body  string `json:"body"`
		} `json:"issue"`
	} `json:"payload"`

	CreatedAt string `json:"created_at"`
}

Event is an entry for recent user activity.

func Events

func Events(username string) ([]Event, error)

Events returns the most recent events for a user.

func (Event) Created

func (e Event) Created() (time.Time, error)

Created returns a time.Time for created_at.

type Profile

type Profile struct {
	User         User         `json:"user"`
	Repositories Repositories `json:"repositories"`
	Emails       []string     `json:"emails"`
}

Profile is a snapshot of a user.

func (*Profile) Fetch

func (p *Profile) Fetch() error

Fetch will attempt to fetch all profile info. Assumes a user has been set and the user has a Login.

type Repositories

type Repositories []Repository

Repositories is a slice of repositories.

func (*Repositories) Fetch

func (rs *Repositories) Fetch(login string) error

Fetch will load repositories from github.com.

type Repository

type Repository struct {
	ID              int    `json:"id"`
	Name            string `json:"name"`
	Description     string `json:"description"`
	Homepage        string `json:"homepage"`
	Language        string `json:"language"`
	StargazersCount int    `json:"stargazers_count"`
	WatchersCount   int    `json:"watchers_count"`
	Forks           int    `json:"forks"`
	Fork            bool   `json:"fork"`
	Owner           User   `json:"owner"`
	CreatedAt       string `json:"created_at"`
	UpdatedAt       string `json:"updated_at"`
}

Repository is a collection of code.

func (Repository) Commits

func (r Repository) Commits() ([]Commit, error)

Commits will fetch a number of commits from the repository. Will fetch the latest 100 commits.

func (Repository) Created

func (r Repository) Created() (time.Time, error)

Created returns a time.Time for created_at.

func (Repository) Updated

func (r Repository) Updated() (time.Time, error)

Updated returns a time.Time for updated_at.

type User

type User struct {
	ID              int    `json:"id"`
	Name            string `json:"name"`
	Email           string `json:"email"`
	Login           string `json:"login"`
	Bio             string `json:"bio"`
	Location        string `json:"location"`
	AvatarURL       string `json:"avatar_url"`
	GravatarURL     string `json:"gravatar_url"`
	Type            string `json:"type"`
	Company         string `json:"company"`
	Blog            string `json:"blog"`
	Hireable        bool   `json:"hireable"`
	TwitterUsername string `json:"twitter_username"`
	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"`
}

User is a Github user.

func (*User) Created

func (u *User) Created() (time.Time, error)

Created returns a time.Time for created_at.

func (*User) Fetch

func (u *User) Fetch() error

Fetch will load a user's data from github.com.

func (*User) Repositories

func (u *User) Repositories() (rs Repositories, err error)

Repositories will fetch all repositories for a user.

func (*User) Updated

func (u *User) Updated() (time.Time, error)

Updated returns a time.Time for updated_at.

Jump to

Keyboard shortcuts

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