github

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseWebHook

func ParseWebHook(messageType string, payload []byte) (any, error)

ParseWebHook parses the raw webhook payload into a typed go-github event value. This wraps github.ParseWebHook so consumers do not need to import go-github directly.

func Ptr

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

Ptr returns a pointer to the given value, equivalent to go-github's github.Ptr.

func WebHookType

func WebHookType(r *http.Request) string

WebHookType returns the X-GitHub-Event header value from the request. This wraps github.WebHookType so consumers do not need to import go-github directly.

Types

type API

type API interface {
	FindIssueCommentWithMarker(ctx context.Context, owner, repo string, issueNumber int, marker string) (*IssueComment, error)
	CreateIssueComment(ctx context.Context, owner, repo string, issueNumber int, body string) (*IssueComment, error)
	UpdateIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) (*IssueComment, error)
	GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)
}

API is the handler-facing interface satisfied by *Client. It exists for dependency injection in handler tests; the shared library provides one implementation. Methods take only the operation's intrinsic arguments; auth is applied by the authTransport on the underlying http client.

type Client

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

Client is the GitHub API client used by handlers. It is built on top of go-github, authenticated with a static token via authTransport.

func NewClient

func NewClient(httpClient *http.Client, token, baseURL string) (*Client, error)

NewClient returns a Client authenticated with the supplied token, issuing requests against baseURL using httpClient's transport.

A nil httpClient falls back to http.DefaultClient. The caller's *http.Client is not mutated; we shallow-copy before installing the auth transport wrapper.

baseURL "" or "https://api.github.com" targets public GitHub. Any other value retargets the underlying go-github client at a GHES instance via WithEnterpriseURLs.

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(ctx context.Context, owner, repo string, issueNumber int, body string) (*IssueComment, error)

CreateIssueComment creates a comment on the specified issue or pull request.

func (*Client) FindIssueCommentWithMarker

func (c *Client) FindIssueCommentWithMarker(ctx context.Context, owner, repo string, issueNumber int, marker string) (*IssueComment, error)

FindIssueCommentWithMarker lists issue comments and returns the first one whose body contains the marker string. Returns nil, nil if no matching comment is found.

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

GetPullRequest retrieves a pull request by number.

func (*Client) UpdateIssueComment

func (c *Client) UpdateIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) (*IssueComment, error)

UpdateIssueComment updates an existing issue comment by ID.

type IssueComment

type IssueComment struct {
	ID   int64
	Body string
}

IssueComment represents a GitHub issue or PR comment.

type PullRequest

type PullRequest struct {
	ID    int64
	State string
	User  PullRequestUser
}

PullRequest represents a GitHub pull request as returned by GetPullRequest.

type PullRequestUser

type PullRequestUser struct {
	Login string
}

PullRequestUser carries the login of a pull request author.

Jump to

Keyboard shortcuts

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