precommit

package
v0.2.0-alpha20251127 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package precommit implements the pre-commit integration using the native autoupdate command. It detects .pre-commit-config.yaml files, runs 'pre-commit autoupdate' to update hook versions, and parses the output to report changes. This follows the manifest-first philosophy by using the native tool that directly updates the configuration file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Repos []Repo `yaml:"repos"`
}

Config represents the structure of .pre-commit-config.yaml.

type Hook

type Hook struct {
	ID string `yaml:"id"`
}

Hook represents a pre-commit hook.

type Integration

type Integration struct{}

Integration implements pre-commit hook updates using native autoupdate command.

func New

func New() *Integration

New creates a new pre-commit integration.

func (*Integration) Apply

Apply executes the update using native pre-commit autoupdate command.

func (*Integration) Detect

func (i *Integration) Detect(ctx context.Context, repoRoot string) ([]*engine.Manifest, error)

Detect finds .pre-commit-config.yaml files in the repository.

func (*Integration) Name

func (i *Integration) Name() string

Name returns the integration identifier.

func (*Integration) Plan

func (i *Integration) Plan(ctx context.Context, manifest *engine.Manifest, planCtx *engine.PlanContext) (*engine.UpdatePlan, error)

Plan determines available updates for pre-commit hooks. For pre-commit, we use the native autoupdate command in dry-run mode.

Note: The pre-commit native command doesn't support policy-based filtering. The planCtx parameter is accepted for interface compatibility but not currently used. Future versions may implement policy filtering by parsing the autoupdate output.

func (*Integration) Validate

func (i *Integration) Validate(ctx context.Context, manifest *engine.Manifest) error

Validate runs pre-commit validate-config.

type Repo

type Repo struct {
	Repo  string `yaml:"repo"`
	Rev   string `yaml:"rev"`
	Hooks []Hook `yaml:"hooks,omitempty"`
}

Repo represents a pre-commit repository.

Jump to

Keyboard shortcuts

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