Documentation ¶
Index ¶
- Constants
- Variables
- func NewErrUnexpectedData(msg string, data []byte) error
- type Action
- type AdvRefs
- type Command
- type CommandStatus
- type Depth
- type DepthCommits
- type DepthReference
- type DepthSince
- type ErrUnexpectedData
- type ReferenceUpdateRequest
- type ReportStatus
- type ServerResponse
- type ShallowUpdate
- type UploadHaves
- type UploadPackRequest
- type UploadPackResponse
- type UploadRequest
Constants ¶
const ( Create Action = "create" Update = "update" Delete = "delete" Invalid = "invalid" )
Variables ¶
var ( // ErrEmptyAdvRefs is returned by Decode if it gets an empty advertised // references message. ErrEmptyAdvRefs = errors.New("empty advertised-ref message") // ErrEmptyInput is returned by Decode if the input is empty. ErrEmptyInput = errors.New("empty input") )
var ( ErrEmptyCommands = errors.New("commands cannot be empty") ErrMalformedCommand = errors.New("malformed command") )
var (
ErrEmpty = errors.New("empty update-request message")
)
var ErrUploadPackResponseNotDecoded = errors.New("upload-pack-response should be decoded")
ErrUploadPackResponseNotDecoded is returned if Read is called without decoding first
Functions ¶
func NewErrUnexpectedData ¶
NewErrUnexpectedData returns a new ErrUnexpectedData containing the data and the message given
Types ¶
type AdvRefs ¶
type AdvRefs struct { // Prefix stores prefix payloads. // // When using this message over (smart) HTTP, you have to add a pktline // before the whole thing with the following payload: // // '# service=$servicename" LF // // Moreover, some (all) git HTTP smart servers will send a flush-pkt // just after the first pkt-line. // // To accommodate both situations, the Prefix field allow you to store // any data you want to send before the actual pktlines. It will also // be filled up with whatever is found on the line. Prefix [][]byte // Head stores the resolved HEAD reference if present. // This can be present with git-upload-pack, not with git-receive-pack. Head *plumbing.Hash // Capabilities are the capabilities. Capabilities *capability.List // References are the hash references. References map[string]plumbing.Hash // Peeled are the peeled hash references. Peeled map[string]plumbing.Hash // Shallows are the shallow object ids. Shallows []plumbing.Hash }
AdvRefs values represent the information transmitted on an advertised-refs message. Values from this type are not zero-value safe, use the New function instead.
func NewAdvRefs ¶
func NewAdvRefs() *AdvRefs
NewAdvRefs returns a pointer to a new AdvRefs value, ready to be used.
func (*AdvRefs) AllReferences ¶
func (a *AdvRefs) AllReferences() (memory.ReferenceStorage, error)
func (*AdvRefs) Decode ¶
Decode reads the next advertised-refs message form its input and stores it in the AdvRefs.
type CommandStatus ¶
type CommandStatus struct { ReferenceName plumbing.ReferenceName Status string }
CommandStatus is the status of a reference in a report status. See ReportStatus struct.
func (*CommandStatus) Error ¶
func (s *CommandStatus) Error() error
Error returns the error, if any.
type Depth ¶
type Depth interface { IsZero() bool // contains filtered or unexported methods }
Depth values stores the desired depth of the requested packfile: see DepthCommit, DepthSince and DepthReference.
type DepthCommits ¶
type DepthCommits int
DepthCommits values stores the maximum number of requested commits in the packfile. Zero means infinite. A negative value will have undefined consequences.
func (DepthCommits) IsZero ¶
func (d DepthCommits) IsZero() bool
type DepthReference ¶
type DepthReference string
DepthReference requests only commits not to found in the specified reference.
func (DepthReference) IsZero ¶
func (d DepthReference) IsZero() bool
type DepthSince ¶
DepthSince values requests only commits newer than the specified time.
func (DepthSince) IsZero ¶
func (d DepthSince) IsZero() bool
type ErrUnexpectedData ¶
ErrUnexpectedData represents an unexpected data decoding a message
func (*ErrUnexpectedData) Error ¶
func (err *ErrUnexpectedData) Error() string
type ReferenceUpdateRequest ¶
type ReferenceUpdateRequest struct { Capabilities *capability.List Commands []*Command Shallow *plumbing.Hash // Packfile contains an optional packfile reader. Packfile io.ReadCloser // Progress receives sideband progress messages from the server Progress sideband.Progress }
ReferenceUpdateRequest values represent reference upload requests. Values from this type are not zero-value safe, use the New function instead.
func NewReferenceUpdateRequest ¶
func NewReferenceUpdateRequest() *ReferenceUpdateRequest
New returns a pointer to a new ReferenceUpdateRequest value.
func NewReferenceUpdateRequestFromCapabilities ¶
func NewReferenceUpdateRequestFromCapabilities(adv *capability.List) *ReferenceUpdateRequest
NewReferenceUpdateRequestFromCapabilities returns a pointer to a new ReferenceUpdateRequest value, the request capabilities are filled with the most optimal ones, based on the adv value (advertised capabilities), the ReferenceUpdateRequest contains no commands
It does set the following capabilities:
- agent
- report-status
- ofs-delta
- ref-delta
- delete-refs
It leaves up to the user to add the following capabilities later:
- atomic
- ofs-delta
- side-band
- side-band-64k
- quiet
- push-cert
type ReportStatus ¶
type ReportStatus struct { UnpackStatus string CommandStatuses []*CommandStatus }
ReportStatus is a report status message, as used in the git-receive-pack process whenever the 'report-status' capability is negotiated.
func NewReportStatus ¶
func NewReportStatus() *ReportStatus
NewReportStatus creates a new ReportStatus message.
func (*ReportStatus) Decode ¶
func (s *ReportStatus) Decode(r io.Reader) error
Decode reads from the given reader and decodes a report-status message. It does not read more input than what is needed to fill the report status.
func (*ReportStatus) Encode ¶
func (s *ReportStatus) Encode(w io.Writer) error
Encode writes the report status to a writer.
func (*ReportStatus) Error ¶
func (s *ReportStatus) Error() error
Error returns the first error if any.
type ServerResponse ¶
ServerResponse object acknowledgement from upload-pack service
type ShallowUpdate ¶
type UploadHaves ¶
UploadHaves is a message to signal the references that a client has in a upload-pack. Do not use this directly. Use UploadPackRequest request instead.
type UploadPackRequest ¶
type UploadPackRequest struct { UploadRequest UploadHaves }
UploadPackRequest represents a upload-pack request. Zero-value is not safe, use NewUploadPackRequest instead.
func NewUploadPackRequest ¶
func NewUploadPackRequest() *UploadPackRequest
NewUploadPackRequest creates a new UploadPackRequest and returns a pointer.
func NewUploadPackRequestFromCapabilities ¶
func NewUploadPackRequestFromCapabilities(adv *capability.List) *UploadPackRequest
NewUploadPackRequestFromCapabilities creates a new UploadPackRequest and returns a pointer. The request capabilities are filled with the most optimal ones, based on the adv value (advertised capabilities), the UploadPackRequest it has no wants, haves or shallows and an infinite depth
func (*UploadPackRequest) IsEmpty ¶
func (r *UploadPackRequest) IsEmpty() bool
IsEmpty a request if empty if Haves are contained in the Wants, or if Wants length is zero
type UploadPackResponse ¶
type UploadPackResponse struct { ShallowUpdate ServerResponse // contains filtered or unexported fields }
UploadPackResponse contains all the information responded by the upload-pack service, the response implements io.ReadCloser that allows to read the packfile directly from it.
func NewUploadPackResponse ¶
func NewUploadPackResponse(req *UploadPackRequest) *UploadPackResponse
NewUploadPackResponse create a new UploadPackResponse instance, the request being responded by the response is required.
func NewUploadPackResponseWithPackfile ¶
func NewUploadPackResponseWithPackfile(req *UploadPackRequest, pf io.ReadCloser) *UploadPackResponse
NewUploadPackResponseWithPackfile creates a new UploadPackResponse instance, and sets its packfile reader.
func (*UploadPackResponse) Close ¶
func (r *UploadPackResponse) Close() error
Close the underlying reader, if any
func (*UploadPackResponse) Decode ¶
func (r *UploadPackResponse) Decode(reader io.ReadCloser) error
Decode decodes all the responses sent by upload-pack service into the struct and prepares it to read the packfile using the Read method
func (*UploadPackResponse) Encode ¶
func (r *UploadPackResponse) Encode(w io.Writer) (err error)
Encode encodes an UploadPackResponse.
func (*UploadPackResponse) Read ¶
func (r *UploadPackResponse) Read(p []byte) (int, error)
Read reads the packfile data, if the request was done with any Sideband capability the content read should be demultiplexed. If the methods wasn't called before the ErrUploadPackResponseNotDecoded will be return
type UploadRequest ¶
type UploadRequest struct { Capabilities *capability.List Wants []plumbing.Hash Shallows []plumbing.Hash Depth Depth }
UploadRequest values represent the information transmitted on a upload-request message. Values from this type are not zero-value safe, use the New function instead. This is a low level type, use UploadPackRequest instead.
func NewUploadRequest ¶
func NewUploadRequest() *UploadRequest
NewUploadRequest returns a pointer to a new UploadRequest value, ready to be used. It has no capabilities, wants or shallows and an infinite depth. Please note that to encode an upload-request it has to have at least one wanted hash.
func NewUploadRequestFromCapabilities ¶
func NewUploadRequestFromCapabilities(adv *capability.List) *UploadRequest
NewUploadRequestFromCapabilities returns a pointer to a new UploadRequest value, the request capabilities are filled with the most optimal ones, based on the adv value (advertised capabilities), the UploadRequest generated it has no wants or shallows and an infinite depth.
func (*UploadRequest) Decode ¶
func (req *UploadRequest) Decode(r io.Reader) error
Decode reads the next upload-request form its input and stores it in the UploadRequest.
func (*UploadRequest) Encode ¶
func (req *UploadRequest) Encode(w io.Writer) error
Encode writes the UlReq encoding of u to the stream.
All the payloads will end with a newline character. Wants and shallows are sorted alphabetically. A depth of 0 means no depth request is sent.
func (*UploadRequest) Validate ¶
func (req *UploadRequest) Validate() error
Validate validates the content of UploadRequest, following the next rules:
- Wants MUST have at least one reference
- capability.Shallow MUST be present if Shallows is not empty
- is a non-zero DepthCommits is given capability.Shallow MUST be present
- is a DepthSince is given capability.Shallow MUST be present
- is a DepthReference is given capability.DeepenNot MUST be present
- MUST contain only maximum of one of capability.Sideband and capability.Sideband64k
- MUST contain only maximum of one of capability.MultiACK and capability.MultiACKDetailed
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package capability defines the server and client capabilities.
|
Package capability defines the server and client capabilities. |
Package sideband implements a sideband mutiplex/demultiplexer
|
Package sideband implements a sideband mutiplex/demultiplexer |