Documentation
¶
Overview ¶
Package git defines types used in the Git remote helpers protocol.
Contrary to the git-remote-helpers documentation, this package refers to commands sent by Git as "Requests" for code readability.
Index ¶
Constants ¶
const ( // OptionSupported is a response to an [OptionRequest] indicating // the option is supported. OptionSupported string = "ok" // OptionNotSupported is a response to an [OptionRequest] indicating // the option is not supported. OptionNotSupported string = "unsupported" )
Variables ¶
var ( // ErrBadRequest indicates a request does not contain sufficient information // to handle. ErrBadRequest = errors.New("request is invalid") // ErrUnexpectedRequest indicates a request was not the expected type. ErrUnexpectedRequest = errors.New("unexpected request") // ErrUnsupportedRequest indicates a request is not supported by this package. ErrUnsupportedRequest = errors.New("unsupported request") // ErrEmptyRequest is an indicator that Git is either breaking up a batch of // requests or has finished sending requests. ErrEmptyRequest = errors.New("empty request") // ErrEndOfInput marks the end of input from Git. ErrEndOfInput = errors.New("end of input") )
Functions ¶
func SupportedCommand ¶
SupportedCommand returns true if a Command is supported.
Types ¶
type CapabilitiesRequest ¶
type CapabilitiesRequest struct {
Cmd Command
}
CapabilitiesRequest is a command received from Git requesting a list of supported capabilities
https://git-scm.com/docs/gitremote-helpers#Documentation/gitremote-helpers.txt-capabilities.
func (*CapabilitiesRequest) Parse ¶
func (r *CapabilitiesRequest) Parse(fields []string) error
Parse decodes request fields ensuring the CapabilitiesRequest is of the correct type and contains sufficient information to handle the request.
Implements Parsable.
func (*CapabilitiesRequest) String ¶
func (r *CapabilitiesRequest) String() string
String condenses CapabilitiesRequest into a string, the raw request received from Git.
type Capability ¶
type Capability = string
Capability defines a git-remote-helper capability.
See https://git-scm.com/docs/gitremote-helpers#_capabilities.
const ( // CapabilityOption indicates a git remote helper is capable // of handling option commands. CapabilityOption Capability = "option" // CapabilityOption indicates a git remote helper is capable // of handling fetch commands. CapabilityFetch Capability = "fetch" // CapabilityOption indicates a git remote helper is capable // of handling push commands. CapabilityPush Capability = "push" )
Capabilities with a '*' prefix marks them as mandatory.
type Command ¶
type Command string
Command is an implemented git-remote-helper command provided by Git.
type FetchRequest ¶
FetchRequest is a command received from Git requesting a fetch operation.
https://git-scm.com/docs/gitremote-helpers#Documentation/gitremote-helpers.txt-fetchsha1name.
func (*FetchRequest) Parse ¶
func (r *FetchRequest) Parse(fields []string) error
Parse decodes request fields ensuring the FetchRequest is of the correct type, is supported, and has a valid value.
Implements Parsable.
func (*FetchRequest) String ¶
func (r *FetchRequest) String() string
String condenses FetchRequest into a string, the raw request received from Git.
type ListRequest ¶
ListRequest is a command received from Git requesting a list of references.
https://git-scm.com/docs/gitremote-helpers#Documentation/gitremote-helpers.txt-list.
func (*ListRequest) Parse ¶
func (r *ListRequest) Parse(fields []string) error
Parse decodes request fields ensuring the ListRequest is of the correct type, is supported, and has a valid value.
Implements Parsable.
func (*ListRequest) String ¶
func (r *ListRequest) String() string
String condenses ListRequest into a string, the raw request received from Git.
type ListResponse ¶
type ListResponse struct {
Reference plumbing.ReferenceName
Commit string
}
ListResponse is a reference and it's commit.
func (*ListResponse) String ¶
func (r *ListResponse) String() string
String condenses the response into a format readable by Git.
type Option ¶
type Option string
Option is an implemented git-remote-helper option sub command provided by Git.
https://git-scm.com/docs/gitremote-helpers#_options.
const (
Verbosity Option = "verbosity"
)
Supported Git options.
type OptionRequest ¶
OptionRequest is a command received from Git requesting an option to be set.
https://git-scm.com/docs/gitremote-helpers#Documentation/gitremote-helpers.txt-optionnamevalue.
func (*OptionRequest) Parse ¶
func (r *OptionRequest) Parse(fields []string) error
Parse decodes request fields ensuring the OptionRequest is of the correct type, is supported, and has a valid value.
Implements Parsable.
func (*OptionRequest) String ¶
func (r *OptionRequest) String() string
String condenses OptionRequest into a string, the raw request received from Git.
type PushRequest ¶
type PushRequest struct {
Cmd Command
Force bool
Src plumbing.ReferenceName
Remote plumbing.ReferenceName
}
PushRequest is a command received from Git requesting a push operation.
https://git-scm.com/docs/gitremote-helpers#Documentation/gitremote-helpers.txt-pushsrcdst.
func (*PushRequest) Parse ¶
func (r *PushRequest) Parse(fields []string) error
Parse decodes request fields ensuring the PushRequest is of the correct type, is supported, and has a valid value.
Implements Parsable.
func (*PushRequest) String ¶
func (r *PushRequest) String() string
String condenses PushRequest into a string, the raw request received from Git.
type PushResponse ¶
type PushResponse struct {
// remote reference
Remote plumbing.ReferenceName
// nil if successful
Error error
}
PushResponse is a status indicating if a push request was handled successfully.
func (*PushResponse) String ¶
func (r *PushResponse) String() string
String condenses the response into a format readable by Git.