Validate push safety
validate_push_safetyPrevent accidental force pushes by verifying the remote commit is an ancestor of the local commit before pushing, rejecting any push that would rewrite remote history.
Instructions
Check that a pending push is not a force push (rule CC301, no_force_push): fails when a
remote_sha is not an ancestor of its local_sha, i.e. the push would rewrite remote history.
Leaves your working tree and commits untouched, but may run git fetch <remote> <ref> to
resolve SHAs, which updates FETCH_HEAD and remote-tracking refs. A SHA that cannot be resolved
even then is a tool error, never a pass. Force pushes are always rejected by this tool;
push.allow_force_push in config cannot re-enable them here.
Returns {status, warnings, checks[]}. status is 'pass', 'fail' or 'skip': only 'fail' is a rejection; 'skip' means every check skipped, so nothing was validated and the result is not approval. warnings is the number of checks with status 'warn'. Each check has: rule_id (stable rule id, e.g. 'CC001'); check (rule name, e.g. 'message'); status 'pass' | 'fail' | 'warn' | 'skip' ('warn' = the config lists the check under warn, so the finding is reported without failing the run; 'skip' = the rule did not run, e.g. the author is in ignore_authors or there was nothing to check); value (what was checked); error (why it failed); suggest (advice for a person); fix (the corrected value when the correction is unambiguous, else ''); docs_url (documentation for the rule). On 'fail', apply a non-empty fix verbatim; when fix is '', rewrite following suggest; then validate again.
Call this before git push. Only the no_force_push rule runs. When it fails there is no
automatic fix (fix is ''): follow suggest, i.e. push without --force/--force-with-lease or
rebase onto the remote first, then validate again.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| config | No | Inline commit-check config overrides as a JSON object, merged on top of the built-in defaults and any config file, e.g. {"warn": ["message"]} or {"commit": {"require_body": true}}. | |
| push_refs | No | Refs about to be pushed, in git pre-push hook stdin format, one ref per line: '<local_ref> <local_sha> <remote_ref> <remote_sha>', e.g. 'refs/heads/main 1a2b3c... refs/heads/main 9f8e7d...'. A remote_sha of 40 zeros means a new branch (never a force push). Every other SHA must resolve to a commit in repo_path (the check runs git merge-base and may fetch the remote ref first); a SHA that still cannot be resolved is a tool error, not a pass, so fetch it first. Omit to check the current branch of repo_path against its upstream instead. Must be non-empty when provided. | |
| repo_path | No | Path to the git repository to validate against. Its cchk.toml or commit-check.toml (also looked up under .github/) is loaded, and a relative config_path is resolved from it. Omit to use the server's working directory. | |
| config_path | No | Path to a commit-check TOML config file, used instead of the repository's own cchk.toml/commit-check.toml; a relative path is resolved from repo_path. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||