github

package
Version: v0.0.0-...-bf65384 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package github provides low-level tools to retrieve information from the Github API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	Get(url string, target interface{}) error
	Repository() (*Repository, error)
	ClosedPullRequests(limit int) ([]PullRequest, error)
	DiffSize(number int) (int, error)
	Comments(number int) ([]Comment, error)
	ReviewRequests(number int) ([]User, error)
}

API is an interface for a collection of methods to retrieve information from Github API

type APIv3

type APIv3 struct {
	HTTPClient client.HTTPClient
	RepoName   string
}

APIv3 is an implementation of API which works with Github REST API (v3)

func (APIv3) ClosedPullRequests

func (a APIv3) ClosedPullRequests(limit int) ([]PullRequest, error)

ClosedPullRequests fetches a list of closed Pull Requests with a `limit`

func (APIv3) Comments

func (a APIv3) Comments(number int) ([]Comment, error)

Comments fetches all the comments of a Pull Request given its `number`

func (APIv3) DiffSize

func (a APIv3) DiffSize(number int) (int, error)

DiffSize fetches the size of the diff of the particular Pull Request given `number`

func (APIv3) Get

func (a APIv3) Get(url string, target interface{}) error

Get makes an HTTP request, checks the response, reads the body and unmarshals it to the `target`

func (APIv3) Repository

func (a APIv3) Repository() (*Repository, error)

Repository fetches the remote repository data

func (APIv3) ReviewRequests

func (a APIv3) ReviewRequests(number int) ([]User, error)

ReviewRequests fetches a list of users which were requested to do a review

type Comment

type Comment struct {
	User User   `json:"user"`
	Body string `json:"body"`
}

Comment is a representation of a Github issue comment

type PullRequest

type PullRequest struct {
	Number         int       `json:"number"`
	Body           string    `json:"body"`
	CreatedAt      time.Time `json:"created_at"`
	MergedAt       time.Time `json:"merged_at,omitempty"`
	User           User      `json:"user"`
	State          string    `json:"state"`
	Assignees      []User    `json:"assignees"`
	DiffURL        string    `json:"diff_url"`
	DiffSize       *int
	ReviewRequests *[]User
	Comments       *[]Comment
}

PullRequest is a representation of the Pull Request the Github API returns

func (*PullRequest) FillDetails

func (p *PullRequest) FillDetails(a API) error

FillDetails makes additional requests to fill details about the Pull Request (such as diff size)

func (PullRequest) IsMerged

func (p PullRequest) IsMerged() bool

IsMerged tells if PullRequest was really merged, not just closed

type Repository

type Repository struct {
	FullName string `json:"full_name"`
}

Repository is a representation of a Github repository which is accessible via API

type ReviewRequestsResponse

type ReviewRequestsResponse struct {
	Users []User `json:"users"`
}

ReviewRequestsResponse is a representation of the /requested_reviewers API response

type User

type User struct {
	Login string `json:"login"`
}

User is a representation of a Github user (e.g. an author of a Pull Request)

Directories

Path Synopsis
Package client contains an implementation of a HTTP client aware of all the Github rules like rate limiting or authenticating
Package client contains an implementation of a HTTP client aware of all the Github rules like rate limiting or authenticating
Package page provides an utility to fetch paginated resources
Package page provides an utility to fetch paginated resources
Package util is a high-level API for Github
Package util is a high-level API for Github

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL