gh

package
v0.0.41 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHTTPUnauthorized added in v0.0.29

func IsHTTPUnauthorized(err error) bool

IsHTTPUnauthorized returns true if the given error is an HTTP 401 Unauthorized error.

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to the argument. It's a convenience function to make working with the API easier: since Go disallows pointers-to-literals, and optional input fields are expressed as pointers, this function can be used to easily set optional fields to non-nil primitives. For example, githubv4.CreatePullRequestInput{Draft: Ptr(true)}

Types

type Client

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

func NewClient

func NewClient(token string) (*Client, error)

NewClient creates a new GitHub client. It takes configuration from the global config.Av.GitHub variable.

func (*Client) ConvertPullRequestToDraft added in v0.0.8

func (c *Client) ConvertPullRequestToDraft(ctx context.Context, id string) (*PullRequest, error)

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(
	ctx context.Context,
	input githubv4.CreatePullRequestInput,
) (*PullRequest, error)

func (*Client) GetPullRequests added in v0.0.4

func (c *Client) GetPullRequests(
	ctx context.Context,
	input GetPullRequestsInput,
) (*GetPullRequestsPage, error)

func (*Client) GetRepositoryBySlug

func (c *Client) GetRepositoryBySlug(ctx context.Context, slug string) (*Repository, error)

func (*Client) MarkPullRequestReadyForReview added in v0.0.8

func (c *Client) MarkPullRequestReadyForReview(
	ctx context.Context,
	id string,
) (*PullRequest, error)

func (*Client) OrganizationTeam added in v0.0.28

func (c *Client) OrganizationTeam(
	ctx context.Context,
	organizationLogin string,
	teamSlug string,
) (*Team, error)

OrganizationTeam returns information about the given team in the given organization.

func (*Client) PullRequest

func (c *Client) PullRequest(ctx context.Context, id string) (*PullRequest, error)

func (*Client) RepoPullRequests

func (c *Client) RepoPullRequests(
	ctx context.Context,
	opts RepoPullRequestOpts,
) (RepoPullRequestsResponse, error)

func (*Client) RequestReviews added in v0.0.28

func (c *Client) RequestReviews(
	ctx context.Context,
	input githubv4.RequestReviewsInput,
) (*PullRequest, error)

RequestReviews requests reviews from the given users on the given pull request.

func (*Client) UpdatePullRequest added in v0.0.6

func (c *Client) UpdatePullRequest(
	ctx context.Context,
	input githubv4.UpdatePullRequestInput,
) (*PullRequest, error)

func (*Client) User added in v0.0.28

func (c *Client) User(ctx context.Context, login string) (*User, error)

User returns information about the given user.

func (*Client) Viewer added in v0.0.29

func (c *Client) Viewer(ctx context.Context) (*Viewer, error)

type GetPullRequestsInput added in v0.0.4

type GetPullRequestsInput struct {
	// REQUIRED
	Owner string
	Repo  string
	// OPTIONAL
	HeadRefName string
	BaseRefName string
	States      []githubv4.PullRequestState
	First       int64
	After       string
}

type GetPullRequestsPage added in v0.0.4

type GetPullRequestsPage struct {
	PageInfo
	PullRequests []PullRequest
}

type PageInfo

type PageInfo struct {
	EndCursor       string
	HasNextPage     bool
	HasPreviousPage bool
	StartCursor     string
}

PageInfo contains information about the current/previous/next page of results when using paginated APIs.

type PullRequest

type PullRequest struct {
	ID                  string
	Number              int64
	HeadRefName         string
	BaseRefName         string
	IsDraft             bool
	Permalink           string
	State               githubv4.PullRequestState
	Title               string
	Body                string
	PRIVATE_MergeCommit struct {
		Oid string
	} `graphql:"mergeCommit"`
	PRIVATE_TimelineItems struct {
		Nodes []struct {
			ClosedEvent struct {
				Closer struct {
					Commit struct {
						Oid string
					} `graphql:"... on Commit"`
				}
			} `graphql:"... on ClosedEvent"`
		}
	} `graphql:"timelineItems(last: 10, itemTypes: CLOSED_EVENT)"`
}

func (*PullRequest) BaseBranchName

func (p *PullRequest) BaseBranchName() string

func (*PullRequest) GetMergeCommit added in v0.0.7

func (p *PullRequest) GetMergeCommit() string

func (*PullRequest) HeadBranchName

func (p *PullRequest) HeadBranchName() string

type PullRequestOpts

type PullRequestOpts struct {
	Owner  string
	Repo   string
	Number int64
}

type RepoPullRequestOpts

type RepoPullRequestOpts struct {
	Owner  string
	Repo   string
	First  int64
	After  string
	States []githubv4.PullRequestState
}

type RepoPullRequestsResponse

type RepoPullRequestsResponse struct {
	PageInfo
	TotalCount   int64
	PullRequests []PullRequest
}

type Repository

type Repository struct {
	ID    string
	Owner struct {
		Login string
	}
	Name string
}

type Team added in v0.0.28

type Team struct {
	ID   githubv4.ID `graphql:"id"`
	Name string      `graphql:"name"`
	Slug string      `graphql:"slug"`
}

type User added in v0.0.28

type User struct {
	ID    githubv4.ID `graphql:"id"`
	Login string      `graphql:"login"`
}

type Viewer added in v0.0.29

type Viewer struct {
	Name  string `graphql:"name"`
	Login string `graphql:"login"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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