github

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package github provides operations on GitHub repos, abstracting away go-github (at least somewhat) to only the operations Librarian needs.

Index

Constants

View Source
const MergeMethodRebase = github.MergeMethodRebase

MergeMethodRebase is a constant alias for the go-github constant.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*github.Client
	// contains filtered or unexported fields
}

Client represents this package's abstraction of a GitHub client, including an access token.

func NewClient

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

NewClient creates a new Client to interact with GitHub.

func (*Client) AddCommentToPullRequest

func (c *Client) AddCommentToPullRequest(ctx context.Context, repo *Repository, prNumber int, comment string) error

AddCommentToPullRequest adds a comment to the pull request identified by repo and prNumber.

func (*Client) AddLabelToPullRequest

func (c *Client) AddLabelToPullRequest(ctx context.Context, prMetadata *PullRequestMetadata, label string) error

AddLabelToPullRequest adds a label to the pull request identified by prMetadata.

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(ctx context.Context, repo *Repository, remoteBranch, title, body string) (*PullRequestMetadata, error)

CreatePullRequest creates a pull request in the remote repo. At the moment this requires a single remote to be configured, which must have a GitHub HTTPS URL. We assume a base branch of "main".

func (*Client) CreateRelease

func (c *Client) CreateRelease(ctx context.Context, repo *Repository, tag, commit, title, description string, prerelease bool) (*github.RepositoryRelease, error)

CreateRelease creates a release on GitHub for the specified commit, including the named tag, with the given title and description.

func (*Client) GetCommit

func (c *Client) GetCommit(ctx context.Context, repo *Repository, sha string) (*github.RepositoryCommit, error)

GetCommit returns the commit in a repository repo with the a commit hash of sha.

func (*Client) GetDiffCommits

func (c *Client) GetDiffCommits(ctx context.Context, repo *Repository, source, target string) ([]*github.RepositoryCommit, error)

GetDiffCommits returns the commits in a repository repo between source and target references (commit hashes, branches etc).

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, repo *Repository, prNumber int) (*github.PullRequest, error)

GetPullRequest fetches information about the pull request identified by repo and prNumber from GitHub.

func (*Client) GetPullRequestCheckRuns

func (c *Client) GetPullRequestCheckRuns(ctx context.Context, pullRequest *github.PullRequest) ([]*github.CheckRun, error)

GetPullRequestCheckRuns fetches the "check runs" (e.g. tests, linters) that have run against a specified pull request. See https://docs.github.com/en/rest/checks/runs for m

func (*Client) GetPullRequestReviews

func (c *Client) GetPullRequestReviews(ctx context.Context, prMetadata *PullRequestMetadata) ([]*github.PullRequestReview, error)

GetPullRequestReviews fetches all reviews for the pull request identified by prMetadata.

func (*Client) GetRawContent

func (c *Client) GetRawContent(ctx context.Context, repo *Repository, path, ref string) (_ []byte, err error)

GetRawContent fetches the raw content of a file within a repository repo, identifying the file by path, at a specific commit/tag/branch of ref.

func (*Client) MergePullRequest

func (c *Client) MergePullRequest(ctx context.Context, repo *Repository, prNumber int, method github.MergeMethod) (*github.PullRequestMergeResult, error)

MergePullRequest merges the pull request identified by repo and prNumber, using the merge method (e.g. rebase or squash) specified as method.

func (*Client) RemoveLabelFromPullRequest

func (c *Client) RemoveLabelFromPullRequest(ctx context.Context, repo *Repository, prNumber int, label string) error

RemoveLabelFromPullRequest removes a label from the pull request identified by prMetadata.

func (*Client) Token

func (c *Client) Token() string

Token returns the access token for Client.

type PullRequest

type PullRequest = github.PullRequest

PullRequest is a type alias for the go-github type.

type PullRequestMetadata

type PullRequestMetadata struct {
	// Repo is the repository containing the pull request.
	Repo *Repository
	// Number is the number of the pull request.
	Number int
}

PullRequestMetadata identifies a pull request within a repository.

type PullRequestReview

type PullRequestReview = github.PullRequestReview

PullRequestReview is a type alias for the go-github type.

type Repository

type Repository struct {
	// The owner of the repository.
	Owner string
	// The name of the repository.
	Name string
}

Repository represents a GitHub repository with an owner (e.g. an organization or a user) and a repository name.

func CreateGitHubRepoFromRepository

func CreateGitHubRepoFromRepository(repo *github.Repository) *Repository

CreateGitHubRepoFromRepository creates a Repository for the underlying github package representation.

func ParseUrl

func ParseUrl(remoteUrl string) (*Repository, error)

ParseUrl parses a GitHub URL (anything to do with a repository) to determine the GitHub repo details (owner and name)

type RepositoryCommit

type RepositoryCommit = github.RepositoryCommit

RepositoryCommit is a type alias for the go-github type.

Jump to

Keyboard shortcuts

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