Documentation
¶
Overview ¶
Package gitproto speaks the git smart HTTP protocol over an object reader: ref advertisement, protocol v2 fetch and ls-refs, and the commands and report of receive-pack. It has no HTTP, grant or storage code.
Index ¶
- Constants
- Variables
- func AdvertiseReceive(w io.Writer, refs []Ref, version int) error
- func AdvertiseUpload(w io.Writer) error
- func GitRefName(stored string) (string, bool)
- func StoredRefName(git string) (string, bool)
- func WriteReport(w io.Writer, unpackErr string, results []Result) error
- type Command
- type Objects
- type Push
- type Ref
- type RequestError
- type Result
- type Upload
Constants ¶
const Agent = "motte"
Agent is the agent capability of both services.
const MaxCommands = 1000
MaxCommands bounds the ref commands of one push.
const MaxTracked = 1000000
MaxTracked bounds the objects that one fetch holds in its sets.
Variables ¶
var ErrNotFound = errors.New("gitproto: object not found")
var ErrTooLarge = errors.New("gitproto: fetch has too many objects")
var Zero gitpack.SHA
Zero is the all-zero name that a ref command uses for an absent ref.
Functions ¶
func AdvertiseReceive ¶
AdvertiseReceive writes the ref advertisement of receive-pack. version is the protocol version that the client asked for, 0 or 1.
func AdvertiseUpload ¶
AdvertiseUpload writes the protocol v2 capability advertisement.
func GitRefName ¶
GitRefName is the git name of a stored ref. A stored name that does not start with refs/ is a branch. A stored name under refs/heads/ has no git name, because the git name would address the branch of the rest.
func StoredRefName ¶
StoredRefName is the stored name of a git ref, or false when no push may write it.
Types ¶
type Command ¶
Command is one ref update of a push. A zero Old creates the ref and a zero New deletes it.
type Objects ¶
type Objects interface {
Get(ctx context.Context, sha gitpack.SHA) (gitpack.Type, []byte, error)
Has(ctx context.Context, shas []gitpack.SHA) ([]bool, error)
}
Objects is the object reader of one repository. Get answers ErrNotFound for an absent object.
type Push ¶
type Push struct {
Commands []Command
ReportStatus bool
// Pack is the pack that follows the commands. It is empty when every command deletes.
Pack []byte
}
Push is a parsed receive-pack request.
type RequestError ¶
type RequestError string
RequestError is a request that the protocol refuses. Its text is safe to send to the client.
func (RequestError) Error ¶
func (e RequestError) Error() string