Help us shape the future of Go! Take the 2026 Go Developer Survey

hook

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package hook asks an external program which post-approval hunks are already reviewed (see "Hunk Filters" in the README).

Index

Constants

View Source
const RequestVersion = 1

RequestVersion is bumped when Request changes shape in a way a hook could misread.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name          string `json:"name"`
	HeadHunks     []Hunk `json:"head_hunks"`
	ApprovalHunks []Hunk `json:"approval_hunks"`
}

type Hunk

type Hunk struct {
	Body string `json:"body"`
}

type Request

type Request struct {
	Version int    `json:"version"`
	Base    string `json:"base"`
	Head    string `json:"head"`
	Ref     string `json:"ref"`
	Files   []File `json:"files"`
}

type Response

type Response struct {
	Reviewed []ReviewedFile `json:"reviewed"`
}

Anything not named in a Response stays in the diff.

func Run

func Run(ctx context.Context, path string, req Request, stderr io.Writer) (Response, error)

Run writes req to the hook's stdin and decodes a Response from its stdout; the path is executed directly, never through a shell.

func (Response) Indexes

func (r Response) Indexes(req Request) (map[string][]int, error)

Indexes validates a response against the request it answers; an unsent name or out-of-range index fails the whole answer rather than being skipped.

type ReviewedFile

type ReviewedFile struct {
	Name    string `json:"name"`
	Indexes []int  `json:"indexes"`
}

ReviewedFile names hunks by index into the same file's head_hunks in the request.

Jump to

Keyboard shortcuts

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