github

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetAuthenticatedUser() (User, error)
	ListPulls(repo string, page int, state string) ([]Pull, error)
	SearchPulls(repo string, page int, q *QueryBuilder) (SearchResponse, error)
	GetPull(repo string, pr int) (Pull, error)
	ListReviews(repo string, pr int, page int) ([]Review, error)
}

Client wraps the GitHub API

func NewOctoClient

func NewOctoClient(cred Credentials) Client

NewOctoClient returns a new OctoClient

type Credentials

type Credentials struct {
	User  string
	Token string
}

Credentials are Basic Authentication credentials for GitHub See https://docs.github.com/en/rest/overview/other-authentication-methods

func (Credentials) EncodeToBasic

func (c Credentials) EncodeToBasic() string

EncodeToBasic encodes the credentials as an RFC-2617 Basic Authorization header

type Label

type Label struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

Label is pull request or issue label

func (Label) String

func (l Label) String() string

String returns the label as a string

type OctoClient

type OctoClient struct {
	BaseEndpoint string
	// contains filtered or unexported fields
}

OctoClient is a GitHub REST API Client

func (*OctoClient) GetAuthenticatedUser

func (o *OctoClient) GetAuthenticatedUser() (User, error)

GetAuthenticatedUser returns the current user

func (*OctoClient) GetPull

func (o *OctoClient) GetPull(repo string, pr int) (Pull, error)

GetPull retrieves details about a pull request

func (*OctoClient) ListPulls

func (o *OctoClient) ListPulls(repo string, page int, state string) ([]Pull, error)

ListPulls returns the list of pull requests

func (*OctoClient) ListReviews

func (o *OctoClient) ListReviews(repo string, pr int, page int) ([]Review, error)

ListReviews returns the list of reviews for a pull request

func (*OctoClient) SearchPulls

func (o *OctoClient) SearchPulls(repo string, page int, q *QueryBuilder) (SearchResponse, error)

SearchPulls searches for pull requests

type Pull

type Pull struct {
	Number      int       `json:"number"`
	Title       string    `json:"title"`
	User        User      `json:"user"`
	Labels      []Label   `json:"labels"`
	IsMerged    bool      `json:"merged"`
	CreatedAt   time.Time `json:"created_at"`
	MergedAt    time.Time `json:"merged_at"`
	ClosedAt    time.Time `json:"closed_at"`
	MergeCommit string    `json:"merge_commit_sha"`
	Reviewers   []User    `json:"requested_reviewers"`
}

Pull is a GitHub Pull Request

type QueryBuilder

type QueryBuilder struct {
	// contains filtered or unexported fields
}

QueryBuilder creates a search query with keywords and qualifiers See https://docs.github.com/en/github/searching-for-information-on-github/searching-issues-and-pull-requests

func Query

func Query(keywords string) *QueryBuilder

Query returns a new QueryBuilder

func (*QueryBuilder) Build

func (q *QueryBuilder) Build() string

Build returns the query as a string

func (*QueryBuilder) IsDraft

func (q *QueryBuilder) IsDraft() *QueryBuilder

IsDraft adds a draft pull request qualifier

func (*QueryBuilder) IsMerged

func (q *QueryBuilder) IsMerged() *QueryBuilder

IsMerged adds a merged pull request qualifier

func (*QueryBuilder) IsMergedAfter

func (q *QueryBuilder) IsMergedAfter(t time.Time) *QueryBuilder

IsMergedAfter filters pull requests that were merged after a given date

func (*QueryBuilder) WithAuthor

func (q *QueryBuilder) WithAuthor(authorLogin string) *QueryBuilder

WithAuthor filters issues and pull requests by the author's login username

func (*QueryBuilder) WithRepo

func (q *QueryBuilder) WithRepo(repo string) *QueryBuilder

WithRepo filters issues and pull requests by repository

func (*QueryBuilder) WithState

func (q *QueryBuilder) WithState(state string) *QueryBuilder

WithState filters issues and pull requests by state

type Repo

type Repo string

Repo is the unique name of a GitHub repository

func (*Repo) UnmarshalJSON

func (r *Repo) UnmarshalJSON(b []byte) error

UnmarshalJSON parses a repo name from a url

type Review

type Review struct {
	ID          int       `json:"id"`
	User        User      `json:"user"`
	State       string    `json:"state"`
	Commit      string    `json:"commit_id"`
	SubmittedAt time.Time `json:"submitted_at"`
}

Review is a Pull Request review

type SearchResponse

type SearchResponse struct {
	Total        int            `json:"total_count"`
	IsIncomplete bool           `json:"incomplete_results"`
	Items        []SearchResult `json:"items"`
}

SearchResponse are the results of an issue or pull request search

type SearchResult

type SearchResult struct {
	Number    int       `json:"number"`
	Title     string    `json:"title"`
	User      User      `json:"user"`
	State     string    `json:"state"`
	Repo      Repo      `json:"repository_url"`
	CreatedAt time.Time `json:"created_at"`
}

SearchResult is a single issue or pull request search result

type User

type User struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Login string `json:"login"`
	Email string `json:"email"`
}

User is a GitHub user

func (User) String

func (u User) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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