rules

package
v0.0.0-...-14dca07 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const AddToIndexType = "add-to-index"
View Source
const CommitMessageType = "commit-message"
View Source
const ExecType = "exec"
View Source
const PrepareMessageType = "prepare-message"
View Source
const ShellScriptType = "shell-script"
View Source
const SuppressCommitFilesType = "suppress-commit-files"
View Source
const SuppressedTextType = "suppressed-text"

Variables

View Source
var (
	PreScripts  byte = 1
	Scripts     byte = 2
	PostScripts byte = 3
)
View Source
var CommandContext = exec.CommandContext

Functions

This section is empty.

Types

type AddToIndex

type AddToIndex struct {
	BaseRule `yaml:",inline"`
	Globs    []Glob `yaml:"globs"`
}

func (*AddToIndex) Check

func (rule *AddToIndex) Check(_ context.Context, _ io.Writer) error

func (*AddToIndex) Compile

func (rule *AddToIndex) Compile(variables map[string]any)

func (*AddToIndex) GetPosition

func (rule *AddToIndex) GetPosition() byte

type BaseRule

type BaseRule struct {
	Type      string `yaml:"type,omitempty"`
	Condition string `yaml:"when,omitempty"`
	// contains filtered or unexported fields
}

func (*BaseRule) Compile

func (rule *BaseRule) Compile(variables map[string]any)

func (*BaseRule) Configure

func (rule *BaseRule) Configure(options ...RuleOption)

func (*BaseRule) GetCondition

func (rule *BaseRule) GetCondition() string

func (*BaseRule) GetPosition

func (rule *BaseRule) GetPosition() byte

func (*BaseRule) GetPrefix

func (rule *BaseRule) GetPrefix() string

func (*BaseRule) GetType

func (rule *BaseRule) GetType() string

type CommandDef

type CommandDef struct {
	Program  string            `yaml:"program"`
	Args     []string          `yaml:"args"`
	Env      map[string]string `yaml:"env"`
	Output   bool              `yaml:"output"`
	Encoding string            `yaml:"encoding"`
	Dir      string            `yaml:"dir"`
}

func (*CommandDef) Compile

func (c *CommandDef) Compile(variables map[string]any)

func (*CommandDef) UnmarshalYAML

func (c *CommandDef) UnmarshalYAML(value *yaml.Node) error

type CommitMessage

type CommitMessage struct {
	BaseRule `yaml:",inline"`
	Prefix   string `yaml:"prefix"`
	Suffix   string `yaml:"suffix"`
	Regexp   string `yaml:"regexp"`
	NotEmpty bool   `yaml:"not-empty"`
}

func (*CommitMessage) Check

func (rule *CommitMessage) Check(_ context.Context, _ io.Writer) error

nolint: cyclop

func (*CommitMessage) Compile

func (rule *CommitMessage) Compile(variables map[string]any)

func (*CommitMessage) Message

func (rule *CommitMessage) Message() (string, error)

type Exec

type Exec struct {
	BaseRule `yaml:",inline"`
	Name     string            `yaml:"name"`
	Env      map[string]string `yaml:"env"`
	Output   bool              `yaml:"output"`
	Dir      string            `yaml:"dir"`
	Commands []CommandDef      `yaml:"commands"`
}

func (*Exec) Check

func (r *Exec) Check(ctx context.Context, output io.Writer) error

func (*Exec) Compile

func (r *Exec) Compile(variables map[string]any)

func (*Exec) GetPosition

func (r *Exec) GetPosition() byte

func (*Exec) GetPrefix

func (r *Exec) GetPrefix() string

type Glob

type Glob struct {
	Pattern    string `yaml:"glob"`
	IsRequired bool   `yaml:"required"`
}

type PrepareMessage

type PrepareMessage struct {
	BaseRule `yaml:",inline"`
	Message  string `yaml:"message"`
}

func (*PrepareMessage) Check

func (rule *PrepareMessage) Check(_ context.Context, _ io.Writer) error

func (*PrepareMessage) Compile

func (rule *PrepareMessage) Compile(variables map[string]any)

type RuleOption

type RuleOption = func(rule *BaseRule)

func WithArgs

func WithArgs(args []string) RuleOption

func WithCwd

func WithCwd(cwd string) RuleOption

func WithEnv

func WithEnv(env []string) RuleOption

WithEnv setups environment variables for BaseRule.

func WithFileSystem

func WithFileSystem(fileSystem billy.Filesystem) RuleOption

func WithRepository

func WithRepository(repository internal.Repository) RuleOption

type ShellScript

type ShellScript struct {
	BaseRule `yaml:",inline"`
	Name     string            `yaml:"name"`
	Shell    string            `yaml:"shell"`
	Commands []string          `yaml:"commands"`
	Env      map[string]string `yaml:"env"`
	Encoding string            `yaml:"encoding"`
	Output   bool              `yaml:"output"`
	Dir      string            `yaml:"dir"`
}

func (*ShellScript) Check

func (rule *ShellScript) Check(ctx context.Context, output io.Writer) error

func (*ShellScript) Compile

func (rule *ShellScript) Compile(variables map[string]any)

func (*ShellScript) GetPosition

func (rule *ShellScript) GetPosition() byte

func (*ShellScript) GetPrefix

func (rule *ShellScript) GetPrefix() string

type SuppressCommitFiles

type SuppressCommitFiles struct {
	BaseRule        `yaml:",inline"`
	Globs           []string `yaml:"globs"`
	RemoveFromIndex bool     `yaml:"remove-from-index"`
}

func (*SuppressCommitFiles) Check

func (rule *SuppressCommitFiles) Check(_ context.Context, _ io.Writer) error

nolint: cyclop

func (*SuppressCommitFiles) Compile

func (rule *SuppressCommitFiles) Compile(variables map[string]any)

func (*SuppressCommitFiles) GetPosition

func (rule *SuppressCommitFiles) GetPosition() byte

type SuppressedText

type SuppressedText struct {
	BaseRule      `yaml:",inline"`
	Substrings    []string `yaml:"substrings"`
	ExcludedGlobs []string `yaml:"exclude"`
}

func (*SuppressedText) Check

func (rule *SuppressedText) Check(_ context.Context, _ io.Writer) error

func (*SuppressedText) Compile

func (rule *SuppressedText) Compile(variables map[string]any)

func (*SuppressedText) GetPosition

func (rule *SuppressedText) GetPosition() byte

Jump to

Keyboard shortcuts

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