pub struct Config {
pub version: String,
pub include: Vec<IncludeEntry>,
pub definitions: BTreeMap<String, DefinitionEntry>,
pub hooks: Hooks,
pub cache: GlobalCache,
}Fields§
§version: StringSchema version
include: Vec<IncludeEntry>External file includes. Import scripts from package.json, Cargo.toml, etc.
Defines named references to external files. Use $include: in hook commands to
reference them.
Example:
include:
- local:
path: package.json
type: json
ref: packagejson
hooks:
pre-commit:
commands:
- $include: packagejson
args: scripts.lintdefinitions: BTreeMap<String, DefinitionEntry>Reusable command definitions for YAML anchors.
Define command templates here using YAML anchors (&name), then reference them with YAML aliases (*name) inside hook command lists. A list alias is automatically flattened into the parent sequence.
Single command anchor:
definitions:
lint: &lint
name: lint
run: cargo clippy -- -D warningsList-of-commands anchor:
definitions:
quality: &quality
- name: lint
run: cargo clippy
- name: audit
run: cargo auditUsage in hooks (list aliases are inlined automatically):
hooks:
pre-commit:
commands:
- name: fmt
run: cargo fmt --check
- *lint # single command
- *quality # expands to two commands inlinehooks: HooksHook definitions. Keys are git hook names (e.g. pre-commit, commit-msg).
cache: GlobalCacheSmart caching — skip commands whose inputs haven’t changed.
Set enabled: true here, then add a cache.inputs list to each
command you want to cache. The cache key is a SHA-256 of the command
script, any extra cache.key strings, and the content of every input
file. A cache hit causes the command to be skipped with a “cached”
message. Cache entries are stored in .githops/cache/ (or cache.dir).
Example:
cache:
enabled: true
hooks:
pre-commit:
commands:
- name: lint
run: cargo clippy -- -D warnings
cache:
inputs: ["src/**/*.rs", "Cargo.toml"]
- name: test
run: cargo test
cache:
inputs: ["src/**/*.rs", "tests/**/*.rs"]
key: ["$RUST_TOOLCHAIN"]Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Config
impl JsonSchema for Config
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read more