Skip to content

feat(clustertool): support custom pre-commit.local hooks - #781

Merged
Boemeltrein merged 2 commits into
mainfrom
codex/pre-commit-local
Nov 21, 2026
Merged

Boemeltrein merged 2 commits into
mainfrom
codex/pre-commit-local

Conversation

@Boemeltrein

@Boemeltrein Boemeltrein commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Description

Custom checks added directly to the generated Git pre-commit hook are lost when ClusterTool regenerates it.

The generated hook now runs an optional .git/hooks/pre-commit.local after the encryption check succeeds. ClusterTool never creates or overwrites this file, so custom checks survive hook regeneration by init, genconfig, and githook.

Encryption failures prevent the local hook from running. A failing local hook aborts the commit. When no local hook exists, the existing encryption-only workflow remains unchanged.

The githook command help documents the behavior and the executable permission required on Linux.

Partially addresses #774.

⚙️ Type of change

  • 🆕 New feature (e.g., bootstrap, cluster config, or automation)
  • 🐛 Bugfix (e.g., node setup, config generation)
  • 🔃 Chart Updates/Changes included with clustertool
  • 🔃 Refactor (internal changes, no functional impact)
  • ⚠️ Breaking change (changes Talos cluster behavior)

🧪 How Has This Been Tested?

Validated using test build test-b63beeb5974f.

  • CI passed Go tests and test builds on Windows and Linux, Go lint, and the init/genconfig/SOPS roundtrip checks.
  • Regression tests perform actual Git commits in temporary repositories with a dummy encryption checker. They cover execution order, missing and failing hooks, preservation during regeneration, and paths containing spaces, quotes, and non-ASCII characters.
  • Manually tested the generated hook and local hook on Linux and Windows with Git for Windows.
  • Actual git commit execution was also tested manually.
  • On Linux, verified that a non-executable local hook fails with exit code 126.
  • Tested integration with the pre-commit framework on Linux: staged SOPS files were encrypted and restaged before local checks ran, excluded SOPS files were skipped, and whitespace issues and deliberately invalid YAML triggered failures.

No live cluster bootstrap or cluster state changes were performed.

  • Run clustertool commands locally
  • Verified cluster bootstrap on Talos nodes
  • Checked generated configs are valid
  • Validated cluster state after changes

📃 Notes:

Users must put their custom checks in .git/hooks/pre-commit.local. On Linux, make it executable with chmod +x .git/hooks/pre-commit.local.

The local hook is not tracked by Git and must be configured for each clone. Any tools it invokes must be available in the environment where the commit runs.

Support for core.hooksPath and protection of existing foreign hooks are outside this change. The generated pre-commit file is still replaced.

No new runtime dependencies are introduced by this change.

🤖 This PR is AI generated.

✔️ Checklist:

  • ⚖️ Followed project style and contribution guidelines
  • 👀 Self-reviewed my changes
  • 🧪 Documented testing steps
  • 🏷️ PR title follows convention:
    • feat(clustertool):
    • fix(clustertool):
    • chore(clustertool):

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f3fbfdea-9a03-47b4-9290-54cd372c3a84
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@trueforge-bot

trueforge-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🚀 HelmRelease CI Report

Overall Status

Stage Result
🔍 Detect HelmReleases success
🧪 Helm Tests skipped

🧪 HelmReleases Tested


⏭️ HelmReleases Skipped


Result

ℹ️ No HelmReleases required testing

@Boemeltrein
Boemeltrein marked this pull request as ready for review November 21, 2026 19:52
@Boemeltrein
Boemeltrein merged commit 6e381c9 into main Nov 21, 2026
11 checks passed
@Boemeltrein
Boemeltrein deleted the codex/pre-commit-local branch November 21, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant