Skip to main content

SCHEMA_JSON

Constant SCHEMA_JSON 

Source
pub const SCHEMA_JSON: &str = "{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"title\": \"Config\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"cache\": {\n      \"description\": \"Smart caching \u{2014} skip commands whose inputs haven\'t changed.\\n\\nSet `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`).\\n\\nExample: ```yaml cache: enabled: true\\n\\nhooks: 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\\\"] ```\",\n      \"allOf\": [\n        {\n          \"$ref\": \"#/definitions/GlobalCache\"\n        }\n      ]\n    },\n    \"definitions\": {\n      \"description\": \"Reusable command definitions for YAML anchors.\\n\\nDefine 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.\\n\\nSingle command anchor: ```yaml definitions: lint: &lint name: lint run: cargo clippy -- -D warnings ```\\n\\nList-of-commands anchor: ```yaml definitions: quality: &quality - name: lint run: cargo clippy - name: audit run: cargo audit ```\\n\\nUsage in hooks (list aliases are inlined automatically): ```yaml hooks: pre-commit: commands: - name: fmt run: cargo fmt --check - *lint        # single command - *quality     # expands to two commands inline ```\",\n      \"type\": \"object\",\n      \"additionalProperties\": {\n        \"$ref\": \"#/definitions/DefinitionEntry\"\n      }\n    },\n    \"hooks\": {\n      \"description\": \"Hook definitions. Keys are git hook names (e.g. pre-commit, commit-msg).\",\n      \"default\": {},\n      \"allOf\": [\n        {\n          \"$ref\": \"#/definitions/Hooks\"\n        }\n      ]\n    },\n    \"version\": {\n      \"description\": \"Schema version\",\n      \"default\": \"1\",\n      \"type\": \"string\"\n    }\n  },\n  \"x-githops-version\": \"0.1.0\",\n  \"definitions\": {\n    \"Command\": {\n      \"type\": \"object\",\n      \"required\": [\n        \"name\",\n        \"run\"\n      ],\n      \"properties\": {\n        \"cache\": {\n          \"description\": \"Cache configuration for this command. Requires `cache.enabled: true` in the top-level config.\",\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/CommandCache\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"depends\": {\n          \"description\": \"Names of commands in this hook that must complete successfully before this command starts. Forms a DAG; cycles are detected and rejected.\",\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"string\"\n          }\n        },\n        \"env\": {\n          \"description\": \"Additional environment variables for this command\",\n          \"type\": \"object\",\n          \"additionalProperties\": {\n            \"type\": \"string\"\n          }\n        },\n        \"name\": {\n          \"description\": \"Human-readable label shown in output\",\n          \"type\": \"string\"\n        },\n        \"run\": {\n          \"description\": \"Shell command to execute. Hook arguments are available as $1, $2, etc.\",\n          \"type\": \"string\"\n        },\n        \"test\": {\n          \"description\": \"Mark this command as a test-only command (informational; not run during normal hooks).\",\n          \"type\": \"boolean\"\n        }\n      }\n    },\n    \"CommandCache\": {\n      \"description\": \"Per-command cache configuration.\",\n      \"type\": \"object\",\n      \"properties\": {\n        \"inputs\": {\n          \"description\": \"File glob patterns treated as inputs. The command is re-run only when the content of any matching file changes. Globs are relative to the repository root.  Example: `[\\\"src/**/*.rs\\\", \\\"Cargo.toml\\\"]`\",\n          \"default\": [],\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"string\"\n          }\n        },\n        \"key\": {\n          \"description\": \"Extra strings mixed into the cache key (e.g. environment variable values or tool version strings).  Example: `[\\\"$RUST_TOOLCHAIN\\\"]`\",\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"string\"\n          }\n        }\n      }\n    },\n    \"CommandEntry\": {\n      \"description\": \"A command entry in a hook\'s command list: either an inline command definition or a reference to a named definition (`$ref: name`).\\n\\nThe `$ref` form lets you reuse commands defined in the `definitions` section without YAML anchors, so changes round-trip correctly through the UI editor.\\n\\nExample using `$ref`: ```yaml hooks: pre-commit: commands: - name: fmt run: cargo fmt --check - $ref: lint   # references definitions.lint ```\",\n      \"anyOf\": [\n        {\n          \"description\": \"A reference to a named definition. Serialises as `{$ref: name}`.\",\n          \"allOf\": [\n            {\n              \"$ref\": \"#/definitions/RefEntry\"\n            }\n          ]\n        },\n        {\n          \"description\": \"An inline command definition.\",\n          \"allOf\": [\n            {\n              \"$ref\": \"#/definitions/Command\"\n            }\n          ]\n        }\n      ]\n    },\n    \"DefinitionEntry\": {\n      \"description\": \"A reusable command definition: a single command mapping or a list of commands.\",\n      \"anyOf\": [\n        {\n          \"description\": \"A list of commands that will be inlined when the anchor is used.\",\n          \"type\": \"array\",\n          \"items\": {\n            \"$ref\": \"#/definitions/Command\"\n          }\n        },\n        {\n          \"description\": \"A single command.\",\n          \"allOf\": [\n            {\n              \"$ref\": \"#/definitions/Command\"\n            }\n          ]\n        }\n      ]\n    },\n    \"GlobalCache\": {\n      \"description\": \"Global cache settings.\",\n      \"type\": \"object\",\n      \"properties\": {\n        \"dir\": {\n          \"description\": \"Override the cache directory (default: `.githops/cache`).\",\n          \"type\": [\n            \"string\",\n            \"null\"\n          ]\n        },\n        \"enabled\": {\n          \"description\": \"Enable caching.  Commands without a `cache` block are always executed.\",\n          \"default\": false,\n          \"type\": \"boolean\"\n        }\n      }\n    },\n    \"HookConfig\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"commands\": {\n          \"description\": \"Commands to run when this hook fires. Each entry is either an inline command or a `$ref` to a definition.\",\n          \"default\": [],\n          \"type\": \"array\",\n          \"items\": {\n            \"$ref\": \"#/definitions/CommandEntry\"\n          }\n        },\n        \"enabled\": {\n          \"description\": \"Whether this hook is active. Set to false to temporarily disable.\",\n          \"default\": true,\n          \"type\": \"boolean\"\n        },\n        \"parallel\": {\n          \"description\": \"Run commands concurrently within each dependency wave.\\n\\nWhen `true`, commands that have no dependency relationship are started at the same time in separate threads.  Commands that share a `depends` link are still serialised \u{2014} the dependent command waits until all its dependencies finish successfully.\\n\\nUse this to speed up independent checks (e.g. lint + test) while keeping ordered steps (e.g. build \u{2192} deploy) sequential.\\n\\nExample: ```yaml hooks: pre-push: parallel: true commands: - name: lint run: cargo clippy - name: test run: cargo test   # runs at the same time as lint ```\",\n          \"default\": false,\n          \"type\": \"boolean\"\n        }\n      }\n    },\n    \"Hooks\": {\n      \"description\": \"All supported git hooks. Configure any hook by adding its name as a key.\",\n      \"type\": \"object\",\n      \"properties\": {\n        \"applypatch-msg\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"commit-msg\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"fsmonitor-watchman\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"p4-changelist\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"p4-post-changelist\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"p4-pre-submit\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"p4-prepare-changelist\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"post-applypatch\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"post-checkout\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"post-commit\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"post-index-change\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"post-merge\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"post-receive\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"post-rewrite\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"post-update\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"pre-applypatch\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"pre-auto-gc\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"pre-commit\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"pre-merge-commit\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"pre-push\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"pre-rebase\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"pre-receive\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"prepare-commit-msg\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"proc-receive\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"push-to-checkout\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"reference-transaction\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"sendemail-validate\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        },\n        \"update\": {\n          \"anyOf\": [\n            {\n              \"$ref\": \"#/definitions/HookConfig\"\n            },\n            {\n              \"type\": \"null\"\n            }\n          ]\n        }\n      }\n    },\n    \"RefEntry\": {\n      \"description\": \"A reference to a named definition in the `definitions` section.\\n\\nSupports two optional overrides that are applied at the point of use, without modifying the shared definition:\\n\\n```yaml hooks: pre-commit: commands: - $ref: lint                  # use definition as-is - $ref: lint args: \\\"--fix\\\"               # appends to the definition\'s run command name: lint-fix              # overrides the display label ```\",\n      \"type\": \"object\",\n      \"required\": [\n        \"$ref\"\n      ],\n      \"properties\": {\n        \"$ref\": {\n          \"description\": \"Name of the definition to reference.\",\n          \"type\": \"string\"\n        },\n        \"args\": {\n          \"description\": \"Extra arguments appended to the definition\'s `run` command.\\n\\nThe final command executed is `{definition.run} {args}`. For example, if the definition runs `npm run lint`, setting `args: \\\"--fix\\\"` produces `npm run lint --fix`.\",\n          \"type\": [\n            \"string\",\n            \"null\"\n          ]\n        },\n        \"name\": {\n          \"description\": \"Override the display name shown in hook output for this specific use. When omitted, the definition\'s own `name` is used.\",\n          \"type\": [\n            \"string\",\n            \"null\"\n          ]\n        }\n      }\n    }\n  }\n}\n";
Expand description

The JSON Schema for githops.yaml, embedded at compile time. Use write_schema to materialize it on disk.