git

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package git is the seam to the service that hosts platform repositories and pull requests.

Index

Constants

View Source
const GitHubName = "github"

GitHubName names the GitHub Host, as saved on an Installation.

View Source
const GitHubPATHelp = `` /* 813-byte string literal not displayed */

GitHubPATHelp explains the token a user needs when the gh CLI is unavailable.

Variables

This section is empty.

Functions

func GitHubTokenFromCLI

func GitHubTokenFromCLI() (string, error)

GitHubTokenFromCLI returns the token of an authenticated gh CLI, or an error if gh is missing or logged out.

func MissingScopes

func MissingScopes(header string, present bool) []string

MissingScopes checks a classic token's X-OAuth-Scopes header. present=false means a fine-grained token.

Types

type GitHub

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

GitHub is the Host adapter for github.com.

func NewGitHub

func NewGitHub(token string) (*GitHub, error)

NewGitHub returns a client authenticated with token.

func (*GitHub) CloneURL

func (c *GitHub) CloneURL(org, name string) string

func (*GitHub) CreatePrivateRepo

func (c *GitHub) CreatePrivateRepo(ctx context.Context, org, name string) error

func (*GitHub) DeleteRepo

func (c *GitHub) DeleteRepo(ctx context.Context, org, name string) error

func (*GitHub) OpenPullRequest

func (c *GitHub) OpenPullRequest(ctx context.Context, owner, repo, head, base, title, body string) (string, error)

OpenPullRequest creates a PR from head into base, or returns the URL of the one already open.

func (*GitHub) Orgs

func (c *GitHub) Orgs(ctx context.Context) ([]string, error)

func (*GitHub) ReleaseTags

func (c *GitHub) ReleaseTags(ctx context.Context, owner, repo string) ([]string, error)

ReleaseTags lists the release tags (vX.Y.Z) of owner/repo, newest first.

func (*GitHub) RepoState

func (c *GitHub) RepoState(ctx context.Context, org, name string) (RepoState, error)

func (*GitHub) Token

func (c *GitHub) Token() string

func (*GitHub) Validate

func (c *GitHub) Validate(ctx context.Context) (string, error)

Validate returns the token owner's login. Classic tokens missing required scopes are rejected; fine-grained tokens carry no scope header and are checked by the API calls themselves.

type Host

type Host interface {
	// Validate checks the token and returns the login it belongs to.
	Validate(ctx context.Context) (login string, err error)
	// Token is the credential used to push to platform repositories.
	Token() string
	// Orgs lists the organizations a platform repository can be created in.
	Orgs(ctx context.Context) ([]string, error)
	RepoState(ctx context.Context, org, name string) (RepoState, error)
	CreatePrivateRepo(ctx context.Context, org, name string) error
	DeleteRepo(ctx context.Context, org, name string) error
	CloneURL(org, name string) string
	// OpenPullRequest creates a PR from head into base, or updates and returns the one already open.
	OpenPullRequest(ctx context.Context, owner, repo, head, base, title, body string) (url string, err error)
}

Host is a git hosting service. GitHub is the only adapter today; the gittest fake is the second.

type RepoState

type RepoState int

RepoState tells what a platform repository already holds.

const (
	RepoMissing RepoState = iota
	RepoEmpty
	RepoNonEmpty
)

Directories

Path Synopsis
Package gittest provides an in-memory git.Host for tests.
Package gittest provides an in-memory git.Host for tests.

Jump to

Keyboard shortcuts

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