gh

package
v0.0.0-...-3d4d46e Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ErrNoIssues is returned if there are no new issues
	ErrNoIssues = Error("no new or updated issues found")
	// ErrNoRepository is returned if the repository couldn't be determined.
	ErrNoRepository = Error("could not determine repository. Make sure it is in the format USER/REPOSITORY")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name string `graphql:"login"`
}

Author is used in gql queries

type Comment

type Comment struct {
	Body   string
	Author struct {
		Login string
	}
	CreatedAt time.Time `graphql:"createdAt"`
}

Comment is used in gql queries

type Comments

type Comments struct {
	Nodes    []Comment
	PageInfo PageInfo `graphql:"pageInfo"`
}

Comments is used in gql queries

type Error

type Error string

Error is used to create new errors

func (Error) Error

func (e Error) Error() string

Error returns the string representation of a error

type GH

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

GH defines the fields needed for a github client

func New

func New(opts ...Option) (*GH, error)

New creates a new github v4 client and prepares the folders and queries

func (*GH) FetchIssues

func (gh *GH) FetchIssues() error

FetchIssues gets all requested issues from a given repository.

type Issue

type Issue struct {
	ID        string    `graphql:"id"`
	Number    int       `graphql:"number"`
	Body      string    `graphql:"body"`
	Title     string    `graphql:"title"`
	Author    Author    `graphql:"author"`
	CreatedAt time.Time `graphql:"createdAt"`
	Milestone Milestone `graphql:"milestone"`
	Comments  Comments  `graphql:"comments(first: $count, after: $commentsCursor)"`
	State     string    `graphql:"state"`
	Closed    bool      `graphql:"closed"`
	ClosedAt  time.Time `graphql:"closedAt"`
}

Issue is returned by a gql query

type IssueConnection

type IssueConnection struct {
	Edges    []IssueEdge `graphql:"edges"`
	PageInfo PageInfo    `graphql:"pageInfo"`
}

IssueConnection is used in gql queries

type IssueEdge

type IssueEdge struct {
	Cursor string `graphql:"cursor"`
	Node   Issue  `graphql:"node"`
}

IssueEdge is used in gql queries

type Milestone

type Milestone struct {
	Title string `graphql:"title"`
}

Milestone is used in gql queries

type Option

type Option func(*Options) error

Option is used to set options

func All

func All(a bool) Option

All sets the issues to download and returns an option

func Count

func Count(i int) Option

Count sets the issue count to fetch at once and returns an option

func Milestones

func Milestones(b bool) Option

Milestones sets the option to download milestones and returns an option

func Output

func Output(t string) Option

Output sets the output folder and returns an option

func Repo

func Repo(r string) Option

Repo extracts the user and repo from a full repo name (eg. S7evinK/issues-to-go)

func Since

func Since(s string) Option

Since sets the time to use for filtering issues and returns an option

func Token

func Token(t string) Option

Token sets the Github access token and returns an option

func UTC

func UTC(b bool) Option

UTC sets the timezone to use for dates and returns an option

type Options

type Options struct {
	Token      string
	User       string
	Repo       string
	OutputPath string
	Count      int
	AllIssues  bool
	Since      time.Time
	Milestones bool
	TZ         *time.Location
}

Options defines all available options for the application

type PageInfo

type PageInfo struct {
	EndCursor   github.String
	HasNextPage bool
}

PageInfo is used in gql queries

type Query

type Query struct {
	Repository struct {
		IssueConnection IssueConnection `graphql:"issues(first: $count, after: $issueCursor, filterBy: $filterBy)"`
	} `graphql:"repository(owner: $owner, name: $name)"`
}

Query is the query executed against the github v4 api

type QueryComments

type QueryComments struct {
	Repository struct {
		Issue Issue `graphql:"issue(number: $issueNumber)"`
	} `graphql:"repository(owner: $owner, name: $name)"`
}

QueryComments is the query executed against the github v4 api

Jump to

Keyboard shortcuts

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