Documentation
¶
Overview ¶
Package gitremote reads and switches a checkout's GitHub origin between the three transport modes: profile (git@github-<profile>:owner/repo.git), ssh (git@github.com:owner/repo.git) and https (https://github.com/owner/repo.git).
Index ¶
Constants ¶
const ( StateManaged = "managed" // a GitHub origin authama can switch StateNoOrigin = "no-origin" // not a repository, or one with no origin StateUnmanaged = "unmanaged" // an origin that is not a GitHub remote )
Checkout states, as `ssh git status` reports them.
const ( ProfileFromRemote = "remote" // the origin names it (profile mode) ProfileFromOwner = "owner" // defaults.git.orgs, then defaults.git.profile ProfileFromFlag = "flag" // --profile on `ssh git use` )
Profile sources: where a managed checkout's profile came from.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Change ¶
type Change struct {
Dir, From, To string
Applied bool
Skipped string // why nothing changed; empty when it changed or would
// Owner and Repo are the origin's; Profile is the one the new URL is built
// for, and ProfileFrom says what chose it. All four are empty when the
// checkout was skipped before its origin was parsed.
Owner, Repo, Profile, ProfileFrom string
}
Change is what `use` did, or would do, to one checkout.
type Checkout ¶ added in v0.1.6
type Checkout struct {
Path string `json:"path"`
State string `json:"state"`
URL string `json:"url,omitempty"`
Mode string `json:"mode,omitempty"`
Owner string `json:"owner,omitempty"`
Repo string `json:"repo,omitempty"`
// Profile is empty when neither the origin nor the manifest names one.
Profile string `json:"profile,omitempty"`
ProfileFrom string `json:"profile_from,omitempty"`
}
Checkout is one checkout's origin, as `ssh git status` reports it. Its JSON is the shape `ssh git status --json` prints, which other tools read: add fields, never rename or remove one, and say so in the CHANGELOG.
type Git ¶
type Git interface {
Origin(dir string) (string, error)
LsRemote(dir, url string) error
SetOrigin(dir, url string) error
}
Git is the slice of git this package needs, so tests can stand in for the network.
type Remote ¶
type Remote struct {
URL string
Mode string // profile, ssh or https
Owner string
Repo string
Profile string // profile mode: the profile whose alias it uses
}
Remote is a parsed GitHub origin.
type Resolution ¶ added in v0.1.6
Resolution is how one GitHub repository would be reached: the profile that owns it, the mode, the remote URL, and the SSH alias and key that URL authenticates with. HostAlias and Key are empty in https mode, which uses the git credential helper rather than a key.
func Resolve ¶ added in v0.1.6
func Resolve(m *manifest.Manifest, owner, repo, mode, profile string) (Resolution, error)
Resolve works out how owner/repo would be reached, touching nothing. The profile is the one given, else the owner's (manifest.ProfileForOwner), which may be empty outside profile mode when no profile is mapped. In profile mode the alias and key are the profile's github.com host; in ssh mode they are Host github.com and defaults.git.profile's key, which that host uses.