github

package
v1.0.1-0...-a23b13b Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	RepoInfo(owner, name string) (RepoInfo, error)
	// Fork creates a fork and returns the fork's owner and name, which may
	// differ from the original if the repository was renamed.
	Fork(owner, name string) (forkOwner, forkName string, err error)
}

Client provides the GitHub API operations needed for fork decisions.

func NewClient

func NewClient() (Client, error)

NewClient creates a Client backed by the GitHub REST API.

type CloneTarget

type CloneTarget struct {
	Repository Repository
	Fork       *Repository
}

CloneTarget describes what to clone and how to configure remotes. When Fork is non-nil, Repository is the upstream and Fork is the user's fork.

func ResolveCloneTarget

func ResolveCloneTarget(owner, name string, fork *bool, client Client, prompter Prompter, diag io.Writer) (CloneTarget, error)

ResolveCloneTarget determines which repository to clone, forking if necessary.

fork controls forking behaviour:

  • nil — default: prompt when the user lacks write access
  • true — always fork (skip prompt); error if forking is disabled
  • false — never fork; clone the original directly without prompting

When a fork is created, CloneTarget.Fork is set; the caller should clone Repository as upstream and add Fork as origin.

diag receives verbose diagnostic messages; pass io.Discard to suppress them.

type Prompter

type Prompter interface {
	Confirm(prompt string, defaultValue bool) (bool, error)
}

Prompter can prompt the user for confirmation.

type RepoInfo

type RepoInfo struct {
	AllowForking  bool
	HasPushAccess bool
}

RepoInfo contains the fields from the GitHub API needed for fork decisions.

type Repository

type Repository struct {
	Owner string
	Name  string
}

func Parse

func Parse(definition string) (Repository, error)

Jump to

Keyboard shortcuts

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