Documentation
¶
Overview ¶
package servegit provides a smart Git HTTP transfer protocol handler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// Dir is a function which takes a repository name and returns an absolute
// path to the GIT_DIR for it.
Dir func(context.Context, string) (string, error)
// ErrorHook is called if we fail to run the git command. The main use of
// this is to inject logging. For example in src-cli we don't use
// sourcegraph/log so this allows us to use stdlib log.
//
// Note: This is required to be set
ErrorHook func(err error, stderr string)
// CommandHook if non-nil will run with the git upload command before we
// start the command.
//
// This allows the command to be modified before running. In practice
// sourcegraph.com will add a flowrated writer for Stdout to treat our
// internal networks more kindly.
CommandHook func(*exec.Cmd)
// Trace if non-nil is called at the start of serving a request. It will
// call the returned function when done executing. If the executation
// failed, it will pass in a non-nil error.
Trace func(ctx context.Context, svc, repo, protocol string) func(error)
// RootFS is a traversal safe API that ensures files outside of the
// root cannot be opened.
RootFS *os.Root
}
Handler is a smart Git HTTP transfer protocol as documented at https://www.git-scm.com/docs/http-protocol.
This allows users to clone any git repo. We only support the smart protocol. We aim to support modern git features such as protocol v2 to minimize traffic.
Click to show internal directories.
Click to hide internal directories.