github

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package github lists and clones repositories from a GitHub org via the GitHub API and the git CLI.

Index

Constants

View Source
const (
	StatusCloned  = "cloned"
	StatusSkipped = "skipped"
	StatusFailed  = "failed"
)

Clone result statuses, the allowed values of CloneResult.Status.

Variables

This section is empty.

Functions

func HasToken added in v0.2.0

func HasToken(ctx context.Context) bool

HasToken reports whether a GitHub token is available, so callers can skip the per-repo status fetch entirely rather than failing once per repo.

Types

type CloneResult

type CloneResult struct {
	Repo   RemoteRepo `json:"repo"`
	Path   string     `json:"path"`
	Status string     `json:"status"`
	Reason string     `json:"reason,omitempty"`
	Error  string     `json:"error,omitempty"`
}

CloneResult is the outcome of cloning one remote repository.

func CloneOrg

func CloneOrg(ctx context.Context, org, root, match string, includeArchived bool, concurrency int) ([]CloneResult, error)

CloneOrg lists an org's repos and clones them into root.

func CloneRepos

func CloneRepos(ctx context.Context, repos []RemoteRepo, root string, concurrency int) []CloneResult

CloneRepos clones each repo into root concurrently, returning results in order.

type PR added in v0.2.0

type PR struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
}

PR is a lightweight view of an open pull request.

type RemoteRepo

type RemoteRepo struct {
	Name     string `json:"name"`
	SSHURL   string `json:"ssh_url"`
	CloneURL string `json:"clone_url"`
	Archived bool   `json:"archived"`
}

RemoteRepo is a repository discovered on the remote (e.g. a GitHub org).

func ListOrgRepos

func ListOrgRepos(ctx context.Context, org, match string, includeArchived bool) ([]RemoteRepo, error)

ListOrgRepos lists an org's repositories, optionally filtered by the match regexp and excluding archived repos.

type RepoStatus added in v0.2.0

type RepoStatus struct {
	OpenPRs int    `json:"open_prs"`
	PRs     []PR   `json:"prs"`      // a capped sample, for the detail view
	CIState string `json:"ci_state"` // "passing" | "failing" | "pending" | "" (none/unknown)
	Err     error  `json:"-"`
}

RepoStatus is a repo's GitHub state: its open pull requests and the latest CI conclusion on the default branch.

func RepoStatusFor added in v0.2.0

func RepoStatusFor(ctx context.Context, owner, repo, ref string) RepoStatus

RepoStatusFor fetches open PRs and the CI status of ref (the default branch) for owner/repo. GitHub-only; needs a token (GITHUB_TOKEN or gh auth token).

Jump to

Keyboard shortcuts

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