Skip to main content

git-hooks

Git hooks management and installation - Automates installation of pre-commit, pre-push, and git safety hooks.

๐Ÿ“– Complete Git Hooks Guide - Detailed documentation with troubleshooting and bypass methods.

Quick Overviewโ€‹

Supernal Coding provides three main git hooks:

  • Pre-commit: Type duplication checking + branch protection
  • Pre-push: Full test suite validation + build checks
  • Git Safety: Main/master branch protection

Usageโ€‹

# Install all git hooks (recommended)
sc git-hooks install

# Install specific hooks
sc git-hooks install pre-commit
sc git-hooks install pre-push
sc git-hooks install all

# Check installation status
sc git-hooks status

# Remove hooks
sc git-hooks remove

Examplesโ€‹

Basic Installationโ€‹

# Install all hooks in current repository
sc git-hooks install

# Output:
# ๐Ÿ”ง Installing Supernal Coding git safety hooks...
# โœ… Pre-commit hook installed (type checking, branch protection)
# โœ… Pre-push hook installed (test validation, build checks)
# โœ… Git safety hooks installed (main branch protection)

Status Checkโ€‹

sc git-hooks status

# Output:
# ๐Ÿ“‹ Git Hooks Status:
# โœ… Pre-commit hook: Installed and executable
# โœ… Pre-push hook: Installed and executable
# โœ… Git safety: Main branch protection active
# ๐Ÿ” Type checking: Enabled (scripts/check-type-duplicates.cjs)

Emergency Bypassโ€‹

# Bypass pre-commit hook (emergency only)
git commit --no-verify -m "Emergency hotfix"

# Bypass pre-push hook (use with caution)
git push --no-verify

# Alternative pre-push bypass
SC_SKIP_PRE_PUSH=true git push

Hook Detailsโ€‹

Pre-commit Hookโ€‹

  • โœ… Type Duplication Checking: Scans for duplicate types/interfaces
  • ๐Ÿ”’ Branch Protection: Prevents direct commits to main/master
  • ๐Ÿ“ CLI Sync: Updates agent rules with latest commands
  • โš ๏ธ Branch Naming: Validates naming conventions

Pre-push Hookโ€‹

  • ๐Ÿงช Test Validation: Runs full test suite (285+ tests)
  • ๐Ÿ—๏ธ Build Validation: Checks if build script succeeds
  • ๐Ÿ” Final Type Check: Last scan for duplications (warning only)
  • ๐Ÿ“Š Progress Display: Shows branch and validation status

Git Safety Hookโ€‹

  • ๐Ÿšซ Main Branch Protection: Absolute prevention of direct commits
  • ๐Ÿ“š Educational Messaging: Guides users to proper workflow
  • ๐Ÿ†˜ Emergency Instructions: Shows bypass methods when needed

Configurationโ€‹

Git hooks behavior is configured via supernal-code.config.toml:

[type_duplication]
enabled = true
pre_commit_hook = true
block_commits_on_duplications = true
allow_force_commits = true

[git_workflow]
protect_main_branches = ["main", "master"]
require_branch_naming = false
auto_sync_cli_docs = true

Troubleshootingโ€‹

Common Issuesโ€‹

  • Hook not executable: chmod +x .git/hooks/*
  • Test failures: Debug with npm test
  • Type checker errors: Check node scripts/check-type-duplicates.cjs
  • Permission denied: Verify repository ownership

Emergency Proceduresโ€‹

  1. Document the reason for any bypass
  2. Fix underlying issue immediately
  3. Re-run validations manually
  4. Inform team about bypass usage

Categoryโ€‹

Git & Workflow


๐Ÿ“– Complete Documentation | ๐Ÿ› Troubleshooting | ๐Ÿš€ Workflow Guide

This documentation reflects the actual implementation of Supernal Coding's git hooks.