github

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: Apache-2.0 Imports: 9 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

This section is empty.

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

NewClient creates a new Client to interact with GitHub.

func (*Client) AddLabelsToIssue added in v0.2.0

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) ClosePullRequest added in v0.2.0

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

ClosePullRequest closes the pull request specified by pull request number.

func (*Client) CreateIssueComment added in v0.2.0

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, isDraft bool) (*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 commit-ish. See https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-commit-ishalsocommittish for definition of commit-ish.

func (*Client) CreateTag added in v0.2.0

func (c *Client) CreateTag(ctx context.Context, tagName, commitSHA string) error

CreateTag creates a lightweight tag in the repository at the given commit SHA. This does NOT create a release, just the tag.

func (*Client) FindMergedPullRequestsWithLabel added in v0.3.0

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

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

func (*Client) FindMergedPullRequestsWithPendingReleaseLabel added in v0.2.0

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 added in v0.2.0

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 added in v0.2.0

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

ReplaceLabels replaces all labels for an issue.

func (*Client) SearchPullRequests added in v0.2.0

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 NewPullRequest added in v0.2.0

type NewPullRequest = github.NewPullRequest

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

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
	// Base URL for API requests.
	BaseURL string
}

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

func ParseRemote added in v0.2.0

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 added in v0.2.0

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