handler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorInvalidHandshake occurs if the client presents an invalid handshake
	ErrorInvalidHandshake = errors.New("invalid handshake from client")
	// ErrorInvalidWantLine occurs if the client sends an invalid want line
	ErrorInvalidWantLine = errors.New("invalid `want` line sent by client")
	// ErrorInvalidHaveLine occurs if the client sends an invalid have line
	ErrorInvalidHaveLine = errors.New("invalid `have` line sent by client")
	// ErrorInvalidPushRefsLine occurs if the client sends an invalid line during ref update
	ErrorInvalidPushRefsLine = errors.New("invalid line sent by client during ref update")
	// ErrorNoHead occurs if a repo has no HEAD
	ErrorNoHead = errors.New("no HEAD in repo")
)

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Decode(*[]byte) error

	// Read bypasses the pkt-line decoding, used when receiving packfiles
	Read(p []byte) (n int, err error)
}

Decoder is used to decode data using pkt-line ACKs are decoded as `nil`.

type Encoder

type Encoder interface {
	Encode([]byte) error
}

Encoder is used for sending data via pkt-line Sending a `nil` does an ACK.

type GitOperation

type GitOperation int

A GitOperation can either be a pull or push

const (
	// GitPull is a pull
	GitPull GitOperation = iota + 1
	// GitPush is a push
	GitPush
)

type GitRequestHandler

type GitRequestHandler struct {
	// contains filtered or unexported fields
}

GitRequestHandler handles the git protocol

func NewGitRequestHandler

func NewGitRequestHandler(out Encoder, in Decoder, repo git.Repo) *GitRequestHandler

NewGitRequestHandler makes a handler for the git protocol

func (*GitRequestHandler) NegotiatePullPackfile

func (h *GitRequestHandler) NegotiatePullPackfile(revisions []git.Revision) (int, error)

NegotiatePullPackfile receives the client's haves and uses the repo to calculate the deltas that should be sent to the client

func (*GitRequestHandler) ReceiveHandshake

func (h *GitRequestHandler) ReceiveHandshake() (GitOperation, error)

ReceiveHandshake reads repo and host info from the client

func (*GitRequestHandler) ReceivePullWants

func (h *GitRequestHandler) ReceivePullWants() ([]string, error)

ReceivePullWants receives the requested refs from the client

func (*GitRequestHandler) ReceivePushRefs

func (h *GitRequestHandler) ReceivePushRefs() ([]RefUpdate, error)

ReceivePushRefs receives the references to be updates in a push from the client

func (*GitRequestHandler) SendPackfile

func (h *GitRequestHandler) SendPackfile(r io.Reader) error

SendPackfile sends a packfile using the side-band-64k encoding

func (*GitRequestHandler) SendRefs

func (h *GitRequestHandler) SendRefs(refs map[string]string, op GitOperation) error

SendRefs sends the given references to the client

func (*GitRequestHandler) ServeRequest

func (h *GitRequestHandler) ServeRequest() error

ServeRequest handles a single git request

type RefUpdate

type RefUpdate struct {
	Name, OldID, NewID string
}

A RefUpdate is a delta for a git reference

Jump to

Keyboard shortcuts

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