github

package
v0.1.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package github provides a wrapper around GitHub's APIs in a manner compliant with the forge.Forge interface.

Index

Constants

View Source
const (
	// DefaultURL is the default URL for GitHub.
	DefaultURL = "https://github.com"

	// DefaultAPIURL is the default URL for the GitHub API.
	DefaultAPIURL = "https://api.github.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CLITokenSource

type CLITokenSource struct{}

CLITokenSource is an oauth2 token source that uses the GitHub CLI to get a token.

This is not super safe and we should probably nuke it.

func (*CLITokenSource) Token

func (ts *CLITokenSource) Token() (*oauth2.Token, error)

Token returns an oauth2 token using the GitHub CLI.

type Forge

type Forge struct {
	// URL is the URL for GitHub.
	// Override this for testing or GitHub Enterprise.
	URL string

	// APIURL is the URL for the GitHub API.
	// Override this for testing or GitHub Enterprise.
	APIURL string

	// Token is the OAuth2 token source to use
	// to authenticate with GitHub.
	Token oauth2.TokenSource

	// Log specifies the logger to use.
	Log *log.Logger
}

Forge builds a GitHub Forge.

func (*Forge) ID

func (*Forge) ID() string

ID reports a unique key for this forge.

func (*Forge) OpenURL

func (f *Forge) OpenURL(ctx context.Context, remoteURL string) (forge.Repository, error)

OpenURL opens a GitHub repository from a remote URL. Returns forge.ErrUnsupportedURL if the URL is not a valid GitHub URL.

type Repository

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

Repository is a GitHub repository.

func (*Repository) EditChange

func (r *Repository) EditChange(ctx context.Context, id forge.ChangeID, opts forge.EditChangeOptions) error

EditChange edits an existing change in a repository.

func (*Repository) FindChangeByID

func (r *Repository) FindChangeByID(ctx context.Context, id forge.ChangeID) (*forge.FindChangeItem, error)

FindChangeByID searches for a change with the given ID.

func (*Repository) FindChangesByBranch

func (r *Repository) FindChangesByBranch(ctx context.Context, branch string) ([]*forge.FindChangeItem, error)

FindChangesByBranch searches for open changes with the given branch name. Returns [ErrNotFound] if no changes are found.

func (*Repository) IsMerged

func (r *Repository) IsMerged(ctx context.Context, id forge.ChangeID) (bool, error)

IsMerged reports whether a change has been merged.

func (*Repository) ListChangeTemplates

func (r *Repository) ListChangeTemplates(ctx context.Context) ([]*forge.ChangeTemplate, error)

ListChangeTemplates returns PR templates defined in the repository.

func (*Repository) SubmitChange

SubmitChange creates a new change in a repository.

Jump to

Keyboard shortcuts

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