github

package
v0.0.0-...-6a95cb0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package github contains libraries for using github repositories that make serverless operations easy to follow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RepoID

type RepoID struct {
	Owner    string
	RepoName string
}

RepoID identifies a github project, including owner & repo.

func NewRepoID

func NewRepoID(or string) (RepoID, error)

NewRepoID creates a new RepoID struct from an owner/repo fragment.

func (RepoID) String

func (r RepoID) String() string

String returns "<owner>/<repo>".

type Repository

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

Repository represents a github repository with a working area and an upstream. The upstream repo must allow PRs. The working fork is usually owned by the user; commits are pushed to branches here and proposed against the upstream repository.

func NewRepository

func NewRepository(ctx context.Context, c *http.Client, upstream RepoID, upstreamBranch string, fork RepoID, ghUser, ghEmail, ghToken string) (Repository, error)

NewRepository creates a wrapper around a git repository which has a fork owned by the user, and an upstream repository configured that PRs can be proposed against.

func (*Repository) CommitFile

func (r *Repository) CommitFile(ctx context.Context, path string, raw []byte, branch, commitMsg string) error

CommitFile creates a commit on a repo's worktree which overwrites the specified file path with the provided bytes.

func (*Repository) CreateOrUpdateBranch

func (r *Repository) CreateOrUpdateBranch(ctx context.Context, branchName string) error

CreateOrUpdateBranch attempts to create a new branch on the fork repo if it doesn't already exist, or rebase it onto HEAD if it does.

func (*Repository) CreatePR

func (r *Repository) CreatePR(ctx context.Context, title, commitBranch string) error

CreatePR creates a pull request. Based on: https://godoc.org/github.com/google/go-github/github#example-PullRequestsService-Create

func (*Repository) ReadFile

func (r *Repository) ReadFile(ctx context.Context, path string) ([]byte, error)

ReadFile returns the contents of the specified path from the configured upstream repo.

func (Repository) String

func (r Repository) String() string

Jump to

Keyboard shortcuts

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