Documentation

Overview

    Package common implements the git pack protocol with a pluggable transport. This is a low-level package to implement new transports. Use a concrete implementation instead (e.g. http, file, ssh).

    A simple example of usage can be found in the file package.

    Index

    Constants

    This section is empty.

    Variables

    View Source
    var (
    	ErrTimeoutExceeded = errors.New("timeout exceeded")
    )

    Functions

    func DecodeUploadPackResponse

    func DecodeUploadPackResponse(r io.ReadCloser, req *packp.UploadPackRequest) (
    	*packp.UploadPackResponse, error,
    )

      DecodeUploadPackResponse decodes r into a new packp.UploadPackResponse

      func NewClient

      func NewClient(runner Commander) transport.Transport

        NewClient creates a new client using the given Commander.

        func ServeUploadPack

        func ServeUploadPack(cmd ServerCommand, s transport.UploadPackSession) (err error)

        Types

        type Command

        type Command interface {
        	// StderrPipe returns a pipe that will be connected to the command's
        	// standard error when the command starts. It should not be called after
        	// Start.
        	StderrPipe() (io.Reader, error)
        	// StdinPipe returns a pipe that will be connected to the command's
        	// standard input when the command starts. It should not be called after
        	// Start. The pipe should be closed when no more input is expected.
        	StdinPipe() (io.WriteCloser, error)
        	// StdoutPipe returns a pipe that will be connected to the command's
        	// standard output when the command starts. It should not be called after
        	// Start.
        	StdoutPipe() (io.Reader, error)
        	// Start starts the specified command. It does not wait for it to
        	// complete.
        	Start() error
        	// Close closes the command and releases any resources used by it. It
        	// will block until the command exits.
        	Close() error
        }

          Command is used for a single command execution. This interface is modeled after exec.Cmd and ssh.Session in the standard library.

          type CommandKiller

          type CommandKiller interface {
          	// Kill and close the session whatever the state it is. It will block until
          	// the command is terminated.
          	Kill() error
          }

            CommandKiller expands the Command interface, enableing it for being killed.

            type Commander

            type Commander interface {
            	// Command creates a new Command for the given git command and
            	// endpoint. cmd can be git-upload-pack or git-receive-pack. An
            	// error should be returned if the endpoint is not supported or the
            	// command cannot be created (e.g. binary does not exist, connection
            	// cannot be established).
            	Command(cmd string, ep *transport.Endpoint, auth transport.AuthMethod) (Command, error)
            }

              Commander creates Command instances. This is the main entry point for transport implementations.

              type ServerCommand

              type ServerCommand struct {
              	Stderr io.Writer
              	Stdout io.WriteCloser
              	Stdin  io.Reader
              }

                ServerCommand is used for a single server command execution.