spec

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultVersion is the default version of the specification
	DefaultVersion = 1
	// DefaultFilename is the default filename of the specification
	DefaultFilename = ".ghc.yaml"
)

Variables

View Source
var ErrHookNotExist = errors.New("hook does not exist")

ErrHookNotExist is an error when the hook does not exist

View Source
var GitHooks = []string{
	"applypatch-msg",
	"commit-msg",
	"post-applypatch",
	"post-checkout",
	"post-commit",
	"post-merge",
	"post-rewrite",
	"pre-applypatch",
	"pre-auto-gc",
	"pre-commit",
	"pre-merge-commit",
	"pre-push",
	"pre-rebase",
	"prepare-commit-msg",
}

GitHooks is a list of git hooks See: https://git-scm.com/docs/githooks

Functions

func Write

func Write(s *Spec, file string, force bool) error

Write writes the specification to the given file.

Types

type Hooks

type Hooks map[string][]string

Hooks is a `git` hook

type Spec

type Spec struct {
	// Version is the version of the specification
	Version int `yaml:"version" validate:"required"`
	// Name is a given name of the project or repository (optional)
	Name string `yaml:"name,omitempty"`
	// Description is a short description of the project or repository (optional)
	Description string `yaml:"description,omitempty"`
	// Hooks is a list of hooks to be executed
	Hooks Hooks `yaml:"hooks" validate:"required"`
	// Stdout is a list of hooks to be executed
	Stdout bool `yaml:"stdout,omitempty"`
	// Stderr is a list of hooks to be
	Stderr bool `yaml:"stderr,omitempty"`

	sync.Mutex `yaml:"-"`
}

Spec is the specification of the repository

func Example

func Example() *Spec

Example returns an example of the Spec struct

func (*Spec) Hook

func (s *Spec) Hook(name string) ([]string, error)

Hook returns the hook with the given name

func (*Spec) UnmarshalYAML

func (s *Spec) UnmarshalYAML(data []byte) error

UnmarshalYAML unmarshals the YAML data into the Spec struct

Jump to

Keyboard shortcuts

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