Repository navigation
feat(guardrails): serve the git hooks to lefthook repositories as a remote #9504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
66298bf
feat(guardrails): serve the git hooks to lefthook repositories as a r…
kyle-sexton 994f69c
feat(guardrails): refuse the remote under a custom lefthook source_dir
kyle-sexton 65f4de6
feat(guardrails): pin the lefthook remote to a guardrails-release branch
kyle-sexton 1c24fe3
ci(guardrails): test the lefthook remote end to end before merge and …
kyle-sexton 71050d1
Merge remote-tracking branch 'origin/main' into feat/guardrails-lefth…
kyle-sexton 40458b4
fix(guardrails): match the lefthook remote by URL and ref, and refuse…
kyle-sexton 5529a1c
fix(guardrails): read the lefthook remotes entry in any key order and…
kyle-sexton c76fdde
fix(guardrails): read source_dir in TOML and JSON lefthook configs, a…
kyle-sexton 70f2fd9
fix(guardrails): read flow-style YAML remotes entries
kyle-sexton ab4c635
feat(guardrails): track main in the lefthook remote and drop the rele…
kyle-sexton 3c085d3
docs(guardrails): say that merging to main runs code in every remote …
kyle-sexton 0267d35
fix(guardrails): ignore trailing comments in remotes entries and find…
kyle-sexton b52b15f
fix(guardrails): match only this ref's lefthook cache in verify
kyle-sexton 7132cf3
Merge remote-tracking branch 'origin/main' into feat/guardrails-lefth…
kyle-sexton 4381c64
fix(guardrails): read remotes entries past a column-0 comment
kyle-sexton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.changes/actionlint/feat-guardrails-lefthook-remote-663be064.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
7 changes: 7 additions & 0 deletions
7
.changes/bash-format/feat-guardrails-lefthook-remote-66f960c2.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
7 changes: 7 additions & 0 deletions
7
.changes/biome-format/feat-guardrails-lefthook-remote-4ac659d2.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
7 changes: 7 additions & 0 deletions
7
.changes/go-format/feat-guardrails-lefthook-remote-12d43cd7.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
7 changes: 7 additions & 0 deletions
7
.changes/guardrails/feat-guardrails-lefthook-remote-51ab54cf.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: minor | ||
| --- | ||
|
|
||
| ### Added | ||
|
|
||
| - `apply install-git-hooks scope=shared` in a lefthook repository, or one with no hook manager yet, now adds one `remotes:` entry to the committed `lefthook.yml` instead of committing copies under `.githooks/guardrails/`: lefthook fetches `git-hooks/lefthook-remote.yml` and its scripts from this marketplace repository's `main` branch and refetches them every 24 hours, so every clone runs the hooks as merged to `main`, with no refresh pull request and no lint exclusion. `install.mjs plan --scope remote` returns the snippet; `verify` reports each entry `ok` once the config carries the remote, `lefthook install` has written the event hook and the remote is fetched, and `missing` with "run lefthook install" otherwise, so the session-start notice also catches a first install made offline. A repository holding the earlier shared copies gets a `migrate` decision (`from: shared`) naming `.githooks/guardrails/` and the old `guardrails-<entry>` jobs to remove. Husky and plain hooks keep the shared copies, and so does a lefthook config that sets its own `source_dir` (a `remote-source-dir` decision), because lefthook then looks for the remote's scripts in a directory the fetched copy does not have. |
7 changes: 7 additions & 0 deletions
7
.changes/instruction-placement/feat-guardrails-lefthook-remote-6f491184.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
7 changes: 7 additions & 0 deletions
7
.changes/markdown-format/feat-guardrails-lefthook-remote-821cb784.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
7 changes: 7 additions & 0 deletions
7
.changes/powershell-format/feat-guardrails-lefthook-remote-433a1c9a.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
7 changes: 7 additions & 0 deletions
7
.changes/ruff-format/feat-guardrails-lefthook-remote-f22965d4.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
7 changes: 7 additions & 0 deletions
7
.changes/typos-format/feat-guardrails-lefthook-remote-5598ea80.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| bump: patch | ||
| --- | ||
|
|
||
| ### Changed | ||
|
|
||
| - The vendored git-hook installer (`lib/git-hooks/install.mjs`) accepts an optional `remote` block in `git-hooks/entries.json` and a `plan --scope remote` that returns a lefthook `remotes:` entry for it; a plugin without the block behaves as before, and `copy --scope remote` is a usage error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env bash | ||
| # Install the pinned lefthook on a Linux x86_64 runner, checksum-verified, into ~/.local/bin and | ||
| # onto $GITHUB_PATH: the lefthook the guardrails remote's end-to-end test | ||
| # (plugins/guardrails/git-hooks/lefthook-remote.test.sh) runs in pr-require-checks.yml's | ||
| # test-bash lane. | ||
| # The version is the one the fleet runs; the hash is the release's published SHA-256 for | ||
| # lefthook_<version>_Linux_x86_64. A cached download under ~/.cache/ci-tools is reused and | ||
| # checked the same way. | ||
| set -euo pipefail | ||
|
|
||
| LEFTHOOK_VERSION=2.2.2 | ||
| LEFTHOOK_SHA256=4fbf89eb7748c6aed84d833ee1a29edac48fae614468ca9a82896ec32f2800b6 | ||
|
|
||
| asset="lefthook_${LEFTHOOK_VERSION}_Linux_x86_64" | ||
| mkdir -p "$HOME/.local/bin" "$HOME/.cache/ci-tools" | ||
| cached="$HOME/.cache/ci-tools/$asset" | ||
| [[ -f "$cached" ]] || curl -fSL --no-progress-meter --retry 3 --retry-all-errors -o "$cached" \ | ||
| "https://github.com/evilmartians/lefthook/releases/download/v$LEFTHOOK_VERSION/$asset" | ||
| cp "$cached" "$HOME/.local/bin/lefthook" | ||
| echo "$LEFTHOOK_SHA256 $HOME/.local/bin/lefthook" | sha256sum -c - | ||
| chmod +x "$HOME/.local/bin/lefthook" | ||
| [[ -z "${GITHUB_PATH:-}" ]] || echo "$HOME/.local/bin" >>"$GITHUB_PATH" | ||
| test "$("$HOME/.local/bin/lefthook" version)" = "$LEFTHOOK_VERSION" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env bash | ||
| # The guardrails commit-msg-convention entry for consumers of the plugin's lefthook remote | ||
| # (plugins/guardrails/git-hooks/lefthook-remote.yml). Lefthook looks up a remote's scripts | ||
| # under this repository's root .lefthook/, so this runs the plugin's own script, which finds its libs beside it. | ||
| exec bash "${BASH_SOURCE[0]%/*}/../../plugins/guardrails/git-hooks/commit-msg-convention.sh" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env bash | ||
| # The guardrails pre-commit-content entry for consumers of the plugin's lefthook remote | ||
| # (plugins/guardrails/git-hooks/lefthook-remote.yml). Lefthook looks up a remote's scripts | ||
| # under this repository's root .lefthook/, so this runs the plugin's own script, which finds its libs beside it. | ||
| exec bash "${BASH_SOURCE[0]%/*}/../../plugins/guardrails/git-hooks/pre-commit-content.sh" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env bash | ||
| # The guardrails reference-verify entry for consumers of the plugin's lefthook remote | ||
| # (plugins/guardrails/git-hooks/lefthook-remote.yml). Lefthook looks up a remote's scripts | ||
| # under this repository's root .lefthook/, so this runs the plugin's own script, which finds its libs beside it. | ||
| exec bash "${BASH_SOURCE[0]%/*}/../../plugins/guardrails/git-hooks/reference-verify.sh" "$@" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.