commit_msg

package
v0.0.250 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 19 Imported by: 1 module, 1 package

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

Index

Constants

View Source
const (
	UnstageKindBinary    = "binary"
	UnstageKindSubmodule = "submodule"
)

Kinds reported by DetectUnstageCandidates.

Variables

This section is empty.

Functions

func Generate

func Generate(dir string, options GenerateOptions) (string, error)

func RunGenCommitMsg

func RunGenCommitMsg(args []string) error

func UnstageCandidatePaths added in v0.0.224

func UnstageCandidatePaths(candidates []UnstageCandidate) []string

UnstageCandidatePaths returns the paths of candidates, preserving order.

Types

type CommitMsg added in v0.0.9

type CommitMsg struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

func SanitizeOrError added in v0.0.63

func SanitizeOrError(raw string) (CommitMsg, error)

SanitizeOrError runs Sanitize and returns an error when the message is rejected.

type GenerateOptions

type GenerateOptions struct {
	Model             string
	AgentRunner       string
	AgentRunnerBinary string
	AgentEnv          map[string]string
	Logger            Logger
}

type Logger

type Logger interface {
	Log(msg string)
	Error(msg string)
}

type SanitizeResult added in v0.0.63

type SanitizeResult struct {
	Msg      CommitMsg
	Changes  []string
	Rejected bool
	Reason   string
}

SanitizeResult is the structured outcome of post-parse commit message sanitization.

func Sanitize added in v0.0.63

func Sanitize(raw string) SanitizeResult

Sanitize applies post-parse anti-pattern cleanup to agent commit-message text. On success returns a usable CommitMsg. On unusable garbage returns Rejected=true.

type UnstageCandidate added in v0.0.224

type UnstageCandidate struct {
	// Path is repo-relative.
	Path string
	// Kind is UnstageKindBinary or UnstageKindSubmodule.
	Kind string
	// Desc describes the file type; only set for binaries.
	Desc string
	// SubmoduleDir is the owning submodule; only set for submodule paths.
	SubmoduleDir string
}

UnstageCandidate is one path that gen-commit-msg removes from the index before generating a message: a staged binary file, or any staged path inside a submodule. Callers that stage files on the user's behalf can ask DetectUnstageCandidates what generation would drop and keep those paths out of the index, so generation never has to mutate a freshly prepared staging area.

func DetectUnstageCandidates added in v0.0.224

func DetectUnstageCandidates(dir string, paths []string) ([]UnstageCandidate, error)

DetectUnstageCandidates reports which of paths gen-commit-msg would unstage. A nil paths list means "the current staged set". Nothing is mutated and the process working directory is restored before returning.

This is the single detector behind both the --dry-run plan and the real unstage step, so external callers and generation can never disagree about which paths are excluded.

Jump to

Keyboard shortcuts

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