Precommit
Description
The Precommit crawler looks recursively for every .pre-commit-config.yaml file from a root directory, and updates the rev pinned by each hook repository.
This crawler is enabled by default, so it can be used either automatically by running updatecli diff from a directory containing the files to update, or by providing a manifest.
The automatic discovery behavior can be tuned by providing a YAML manifest with a precommit crawler in top-level directive autodiscovery as explained in the "Autodiscovery" page.
Generated manifests
Each repository produces a gittag source resolving the latest tag, and a target writing the new value to the repository’s rev.
The version filter is narrowed per repository from the currently pinned revision, so a hook on v4.5.0 is filtered with >=4.5.0.
Digest pinning
Unlike most crawlers, digest defaults to false, so hooks are pinned to a tag. Set digest: true to resolve and write the commit SHA behind that tag instead, which is the form pre-commit itself recommends for untrusted repositories.
Limitations
A
repo: localentry declares hooks that live in the repository itself, so it has no upstream revision and is skipped.Only files named exactly
.pre-commit-config.yamlare scanned.
Manifest
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| digest | boolean | “digest” defines whether the generated manifests pin the commit hash instead of the tag. default: false remark:
| |
| ignore | array | “ignore” defines rules to exclude matching hook repositories from the autodiscovery. remark:
| |
| path | string | “path” defines a “.pre-commit-config.yaml” path pattern. remark:
| |
| repos | object | “repos” defines the hook repositories to match, keyed by repository URL. remark:
| |
| only | array | “only” defines rules to restrict the autodiscovery to matching hook repositories. remark:
| |
| path | string | “path” defines a “.pre-commit-config.yaml” path pattern. remark:
| |
| repos | object | “repos” defines the hook repositories to match, keyed by repository URL. remark:
| |
| rootdir | string | “rootdir” defines the directory where the crawler starts searching for “.pre-commit-config.yaml” files. default: the scm directory when “scmid” is set, otherwise the directory relative paths resolve from, by default the working directory. remark:
| |
| versionfilter | object | “versionfilter” defines the version filter used by the generated manifests. default: kind “semver” with pattern “*”, any version greater than or equal to the current one. remark:
example: | |
| kind | string | “kind” defines the versioning scheme used to select a version. default: latest remark:
example:
| |
| pattern | string | “pattern” defines the version pattern, according to “kind”. default:
remark:
example:
| |
| regex | string | “regex” defines the regular expression extracting the version from each entry. remark:
example:
| |
| replaceall | object | “replaceall” applies a regular expression replacement to each version before filtering. remark:
example: turns “curl-8_15_0” into “curl-8.15.0”. | |
| pattern | string | “pattern” defines the regular expression matching the text to replace. example:
| |
| replacement | string | “replacement” defines the text replacing each match of “pattern”. remark:
example:
| |
| strict | boolean | “strict” enforces strict semantic versioning rules when parsing versions. default: false remark:
|
Example
# updatecli.d/default.yaml
name: "precommit autodiscovery"
scms:
default:
kind: git
spec:
url: https://github.com/updatecli/updatecli.git
branch: "main"
autodiscovery:
scmid: default
crawlers:
precommit:
spec:
digest: true