Documentation
¶
Overview ¶
Package hookd is the unix-socket bridge between git hooks and the daemon. The hook process (gitbayd in hook mode) computes git facts — it inherits git's quarantine environment, which the daemon does not see — and sends them here; the daemon answers with a policy decision.
pre-receive is two-phase when the repo requires signed commits: the first response sets NeedCommits, and the hook answers with the raw commit objects (only the hook can read them out of quarantine) for verification.
Index ¶
Constants ¶
const ( EnvSocket = "GITBAY_HOOK_SOCKET" EnvRepoID = "GITBAY_REPO_ID" EnvUserID = "GITBAY_USER_ID" )
Env variable names passed to git transport subprocesses and inherited by hooks.
Variables ¶
This section is empty.
Functions ¶
func Serve ¶
Serve listens on the unix socket until the listener is closed.
func SocketPath ¶
SocketPath returns the hook socket location. It prefers the server root, but unix socket paths are capped (~104 bytes on macOS, 108 on Linux), so deep roots fall back to a hashed name under the system temp directory. Hooks receive the chosen path via GITBAY_HOOK_SOCKET, so both sides always agree.
Types ¶
type RawCommit ¶
RawCommit is one incoming commit object. When NeedCommits is set the hook streams these one per JSON value and ends with a zero one, rather than sending a single message holding every commit in the push: an initial push of a large history is tens of thousands of them (#100).
type Request ¶
type Response ¶
type Response struct {
Allow bool `json:"allow"`
Message string `json:"message,omitempty"`
NeedCommits bool `json:"need_commits,omitempty"`
}
func Ask ¶
func Ask(socketPath string, req Request, stream func(emit func(RawCommit) error) error) (Response, error)
Ask sends one request from the hook process to the daemon. stream is called if the daemon asks for the incoming commit objects; it hands each commit to the callback, which writes it on the wire.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Source Files
¶
- hookd.go