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

hook

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package hook runs the user-supplied commands around a run: a pre-exec hook whose failure aborts the update, and a post-exec hook told whether anything changed. The hook contract travels in environment variables, always all set, so a stale inherited value can never leak a false fact into a hook.

Index

Constants

View Source
const (
	// PhaseEnv tells the hook which side of the run it is on: pre or post.
	PhaseEnv = "CLOVER_PHASE"
	// ChangedEnv tells the hook whether the run rewrote anything: unknown in
	// pre (the run has not happened), true or false in post.
	ChangedEnv = "CLOVER_CHANGED"
	// SuccessEnv tells the hook whether the run finished cleanly: unknown in
	// pre, false in post when any marker failed or a write errored.
	SuccessEnv = "CLOVER_SUCCESS"
)

Environment variable names of the hook contract.

View Source
const (
	PhasePre  = "pre"
	PhasePost = "post"
)

Phase values for PhaseEnv.

Variables

This section is empty.

Functions

func DefaultShell

func DefaultShell() string

DefaultShell returns the platform's default hook shell, which the --exec-shell flag advertises and falls back to.

func Post

func Post(ctx context.Context, shell, command string, changed, success bool) error

Post runs the post-exec hook, telling it whether the run changed anything and whether it finished without failures.

func Pre

func Pre(ctx context.Context, shell, command string) error

Pre runs the pre-exec hook. The run outcome is unknown at this point, so the contract carries unknown for both facts.

Types

This section is empty.

Jump to

Keyboard shortcuts

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