githubutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindPATFlag

func BindPATFlag() *string

BindPATFlag returns a flag to specify the personal access token.

func BindRepoFlag

func BindRepoFlag() *string

BindRepoFlag returns a flag to specify a GitHub repo to target. Parse it with ParseRepoFlag.

func FetchEachPage

func FetchEachPage(f func(options github.ListOptions) (*github.Response, error)) error

FetchEachPage helps fetch all data from a GitHub API call that may or may not span multiple pages. FetchEachPage initially calls f with no paging parameters, then inspects the GitHub response to see if there are more pages to fetch. If so, it constructs paging parameters that will fetch the next page and calls f again. This repeats until there aren't any more pages.

Note that FetchEachPage doesn't process any of the result data, and doesn't actually call the GitHub API. f must do this itself. This allows FetchEachPage to work with any GitHub API.

func NewClient

func NewClient(ctx context.Context, pat string) (*github.Client, error)

NewClient creates a GitHub client using the given personal access token.

func ParseRepoFlag

func ParseRepoFlag(repo *string) (owner, name string, err error)

ParseRepoFlag splits a given repo (owner/name) into owner and name, or returns an error.

func Retry

func Retry(f func() error) error

Retry runs f up to 'retryAttempts' times, printing the error if one is encountered. Handles GitHub rate limit exceeded errors by waiting, if the reset will happen reasonably soon.

Types

This section is empty.

Jump to

Keyboard shortcuts

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