github

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 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) 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) 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) 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 added in v0.1.1

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

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