github

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: Apache-2.0 Imports: 8 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, repo *Repository) (*Client, error)

NewClient creates a new Client to interact with GitHub.

func (*Client) AddLabelsToIssue

func (c *Client) AddLabelsToIssue(ctx context.Context, repo *Repository, number int, labels []string) error

AddLabelsToIssue adds labels to an existing issue in a GitHub repository.

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(ctx context.Context, number int, comment string) error

CreateIssueComment adds a comment to the issue number provided.

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(ctx context.Context, repo *Repository, remoteBranch, baseBranch, 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, tagName, name, body, commitish string) (*github.RepositoryRelease, error)

CreateRelease creates a tag and release in the repository at the given commitish.

func (*Client) FindMergedPullRequestsWithPendingReleaseLabel

func (c *Client) FindMergedPullRequestsWithPendingReleaseLabel(ctx context.Context, owner, repo string) ([]*PullRequest, error)

FindMergedPullRequestsWithPendingReleaseLabel finds all merged pull requests with the "release:pending" label.

func (*Client) GetLabels

func (c *Client) GetLabels(ctx context.Context, number int) ([]string, error)

GetLabels fetches the labels for an issue.

func (*Client) GetPullRequest

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

GetPullRequest gets a pull request by its number.

func (*Client) GetRawContent

func (c *Client) GetRawContent(ctx context.Context, path, ref string) ([]byte, 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) ReplaceLabels

func (c *Client) ReplaceLabels(ctx context.Context, number int, labels []string) error

ReplaceLabels replaces all labels for an issue.

func (*Client) SearchPullRequests

func (c *Client) SearchPullRequests(ctx context.Context, query string) ([]*PullRequest, error)

SearchPullRequests searches for pull requests in the repository using the provided raw query.

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 FetchGitHubRepoFromRemote

func FetchGitHubRepoFromRemote(repo gitrepo.Repository) (*Repository, error)

FetchGitHubRepoFromRemote parses the GitHub repo name from the remote for this repository. There must be a remote named 'origin' with a GitHub URL (as the first URL), in order to provide an unambiguous result. Remotes without any URLs, or where the first URL does not start with https://github.com/ are ignored.

func ParseRemote

func ParseRemote(remote string) (*Repository, error)

ParseRemote parses a GitHub remote (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.

type RepositoryRelease

type RepositoryRelease = github.RepositoryRelease

RepositoryRelease 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