Documentation
¶
Overview ¶
Package forge connects git-stack to the host of a repository through a provider plugin, or to no host at all (provider "none").
Index ¶
- Constants
- Variables
- func Describe(t Transport) (*protocol.Info, error)
- func Detect(t Transport, repo protocol.Repo) bool
- func GuessProvider(host string) string
- func SSHHostname(host string) string
- func SetBlock(desc, block string) string
- func StripBlock(desc string) string
- type Block
- type Branch
- type CR
- type DetectCache
- type FileCache
- type Finder
- type Forge
- type Info
- type NewCR
- type Repo
- type RepoSettings
- type Resolver
- type StackInfo
- type StackItem
- type Transport
- type Update
Constants ¶
const ( // Marker is searched for to find stacks on the host. Marker = "git-stack:begin" // LegacyMarker starts blocks written by glab-stax, which are still read. LegacyMarker = "glab-stax:begin" // RepoURL is git-stack's home page, linked from every block. RepoURL = "https://github.com/mhvelplund/git-stack" )
const ( StateOpen = protocol.StateOpen StateClosed = protocol.StateClosed StateMerged = protocol.StateMerged StateMerging = protocol.StateMerging )
CR states.
const ConfigKey = "git-stack.provider"
ConfigKey is the git config key that pins a repository's provider.
const None = "none"
None is the provider used when the host is unknown: plain git, no CRs.
Variables ¶
var NoneInfo = Info{ Name: None, Protocol: protocol.Version, Terms: protocol.Terms{Short: "PR", Long: "pull request", Ref: "#%d"}, }
NoneInfo describes provider "none".
Functions ¶
func GuessProvider ¶
GuessProvider names the provider for host from its name alone: a known public host, an Azure DevOps organization (<org>.visualstudio.com), or a self-hosted one whose first label names the product (github.example.com, gitlab.example.com). It returns "" if it cannot tell.
func SSHHostname ¶
SSHHostname resolves an ssh config alias (e.g. "work-gitlab") to its real hostname with `ssh -G`. It returns host unchanged if it looks like a real hostname or cannot be resolved.
func StripBlock ¶
StripBlock removes the stack block from desc. Text before and after a block in the middle stays in separate paragraphs.
Types ¶
type Block ¶
type Block struct {
Style string // a protocol.Block* constant; "" is BlockHTMLComment
Short string // e.g. PR
// Ref writes a reference to CR n, e.g. "!12" or a Markdown link.
Ref func(n int) string
}
Block renders stack blocks for one forge.
type Branch ¶
Type aliases keep the core's code short; the types live in pkg/protocol so that plugins outside this module can use them.
type CR ¶
Type aliases keep the core's code short; the types live in pkg/protocol so that plugins outside this module can use them.
type DetectCache ¶
type DetectCache interface {
Get(host string) (provider string, ok bool)
Set(host, provider string)
}
DetectCache stores the outcome of asking plugins about a host.
type FileCache ¶
FileCache is a DetectCache in a JSON file, e.g. in the git common dir.
type Finder ¶
type Finder struct {
// Dirs are searched before PATH, e.g. the directory of git-stack itself.
Dirs []string
}
Finder locates provider plugins.
func DefaultFinder ¶
func DefaultFinder() Finder
DefaultFinder searches next to the running executable, then PATH.
type Forge ¶
Forge is a provider bound to one repository.
func (*Forge) Block ¶
Block returns the block renderer for f. url returns a CR's web URL, or "", for hosts without a short reference syntax.
type Info ¶
Type aliases keep the core's code short; the types live in pkg/protocol so that plugins outside this module can use them.
type NewCR ¶
Type aliases keep the core's code short; the types live in pkg/protocol so that plugins outside this module can use them.
type Repo ¶
Type aliases keep the core's code short; the types live in pkg/protocol so that plugins outside this module can use them.
func ParseRemoteURL ¶
ParseRemoteURL extracts host and project path from a git remote URL (https, ssh:// or scp-like git@host:path).
type RepoSettings ¶
type RepoSettings = protocol.RepoSettings
Type aliases keep the core's code short; the types live in pkg/protocol so that plugins outside this module can use them.
type Resolver ¶
type Resolver struct {
Finder Finder
// Explicit is the provider chosen by flag or git config; "" to detect.
Explicit string
// Warn reports a fallback to provider none.
Warn func(format string, args ...any)
// Transport overrides how plugins are run (tests).
Transport func(path string) Transport
// Cache remembers which provider claimed an unknown host ("none" if no
// plugin did), so plugins are not asked on every command. It may be nil.
Cache DetectCache
}
Resolver picks the provider for a repository.
type StackInfo ¶
type StackInfo struct {
Version int `json:"v"`
Trunk string `json:"trunk"`
Items []StackItem `json:"crs"` // bottom first
}
StackInfo is the machine-readable part of the block in each CR description.
func ParseBlock ¶
ParseBlock extracts stack info from a CR description.
func (*StackInfo) UnmarshalJSON ¶
UnmarshalJSON also reads the glab-stax format ("mrs" of {"iid", "branch"}).
type Transport ¶
Transport runs one operation of a provider plugin.
func ExecTransport ¶
ExecTransport runs the plugin executable at path.
func LocalTransport ¶
LocalTransport runs p in this process, through the same JSON encoding as ExecTransport. Tests use it, and so can built-in providers.