gates

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gates implements the git hooks and CI gate (docs/spec/integrations.md, Gates).

Index

Constants

This section is empty.

Variables

View Source
var ConventionalRe = regexp.MustCompile(`^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([^()\r\n]+\))?!?: \S.*$`)

ConventionalRe matches a Conventional Commits 1.0 header.

View Source
var Hooks = []string{"pre-commit", "commit-msg", "pre-push"}

Hooks managed by aitk.

Functions

func AddTrailers

func AddTrailers(root, msgFile, taskID, tool string) error

AddTrailers appends AI-Task / AI-Tool trailers to the message file when not already present.

func DefaultBase

func DefaultBase(root, defaultBranch string) string

DefaultBase picks the CI comparison base: GITHUB_BASE_REF / CI_MERGE_REQUEST_TARGET_BRANCH_NAME, else the merge base with origin/<default branch>, else "" (nothing to compare).

func HooksDir

func HooksDir(root string) (string, error)

HooksDir returns the effective hooks directory (respects core.hooksPath).

func Install

func Install(root string) ([]string, error)

Install adds aitk's block to each hook. Shell hooks get the block after their shebang; hooks in other languages are kept as <hook>.aitk-user and run by a small shell wrapper, so existing hooks always keep working.

func MessageHeader added in v2.5.1

func MessageHeader(msg string) string

MessageHeader is the first non-empty line of a commit message as git will record it: comment lines dropped, and nothing below the scissors line of ` + "`git commit -v`" + `.

func Uninstall

func Uninstall(root string) ([]string, error)

Uninstall removes aitk's block; a wrapped hook is restored, and a hook left with only a shebang is deleted.

Types

type Violation

type Violation struct {
	Gate   string `json:"gate"`
	File   string `json:"file,omitempty"`
	Line   int    `json:"line,omitempty"`
	Detail string `json:"detail"`
}

Violation is one gate failure.

func CI

func CI(root, base string) ([]Violation, error)

CI runs the gates over base..HEAD: commit messages and secrets in the diff.

func CheckMessage

func CheckMessage(msg string) *Violation

CheckMessage validates a commit message header. Merge, revert, fixup, and squash commits pass.

func PreCommit

func PreCommit(root string) ([]Violation, error)

PreCommit checks staged changes: secrets in added lines and validity of aitk files.

func (Violation) String

func (v Violation) String() string

Jump to

Keyboard shortcuts

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