Skip to main content

A CLI tool to quickly set up and check pre-commit Git hooks for Python, JS, and TS projects.

Project description

Quick Git Hooks

A CLI tool to quickly set up and manage pre-commit Git hooks for Python, JavaScript, and TypeScript projects.

Features

  • 🚀 One-command setup of pre-commit hooks
  • 🔍 Automatic detection of Python/JS/TS projects
  • 📝 Comprehensive documentation and guides
  • ✨ Pre-configured hooks for:
    • Code formatting (black, prettier)
    • Linting (flake8, eslint with flat config)
    • Import sorting (isort)
    • Commit message formatting (commitizen)
    • Branch naming conventions
  • 🔄 Easy hook management and customization
  • 🛠️ Modern tooling support:
    • ESLint flat config (eslint.config.js)
    • Automatic tool installation
    • Smart file ignoring (.prettierignore)

Installation

pip install quick-git-hooks

Quick Start

  1. Navigate to your Git repository:

    cd your-repository
    
  2. Run the setup command:

    quick-git-hooks setup
    

    This will:

    • Create .pre-commit-config.yaml with recommended hooks
    • Create GIT_HOOKS_GUIDE.md with detailed documentation
    • For JS/TS projects:
      • Create eslint.config.js with modern flat config
      • Install required tools globally (prettier, eslint)
    • Install pre-commit hooks
    • Install required Python tools
    • Provide instructions for any missing dependencies
  3. Check the setup status:

    quick-git-hooks check
    
  4. Review GIT_HOOKS_GUIDE.md for:

    • Pre-configured git hooks and their purpose
    • Recommended branching strategy (Git Flow)
    • How to customize hooks
    • Common commands and troubleshooting

Commands

Setup

quick-git-hooks setup [--overwrite]  # Set up hooks (--overwrite to replace existing config)

Check

quick-git-hooks check  # Verify setup and dependencies

Run Hooks Manually

quick-git-hooks run hooks  # Run all hooks on all files

Skip Hooks

git commit --no-verify  # Skip pre-commit and commit-msg hooks
git push --no-verify   # Skip pre-push hooks

Included Hooks

  • Code Quality

    • black (Python formatting)
    • flake8 (Python linting)
    • isort (Python import sorting)
    • prettier (JS/TS formatting)
    • eslint (JS/TS linting with modern flat config)
  • Commit Quality

    • commitizen (Conventional Commits)
    • merge conflict detection
    • trailing whitespace fixing
    • end of file fixing
  • Branch Quality

    • Branch naming convention enforcement
    • Protected branch checks

See GIT_HOOKS_GUIDE.md for detailed configuration options.

Configuration Files

When JS/TS files are detected, the following files are automatically created:

  • eslint.config.js: Modern ESLint flat configuration with:
    • JavaScript and TypeScript support
    • Recommended rules and best practices
    • Customizable ignore patterns
    • TypeScript-specific rules when needed

Development

  1. Clone the repository:

    git clone https://github.com/Eng-Elias/quick-git-hooks
    cd quick-git-hooks
    
  2. Create and activate virtual environment:

    python -m venv .venv
    # On Windows:
    .\.venv\Scripts\activate
    # On Unix:
    source .venv/bin/activate
    
  3. Install development dependencies:

    make install-dev
    
  4. Available make commands:

    make install       # Install package from local sources
    make install-dev   # Install in editable mode with dev dependencies
    make build         # Build package distribution
    make publish       # Upload to PyPI (requires twine setup)
    make clean         # Clean build artifacts
    

Requirements

  • Python ≥ 3.7
  • Git
  • For Python hooks: black, flake8, isort
  • For JS/TS hooks: Node.js, npm (for global installation of prettier and eslint)
  • For commit messages: commitizen

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quick_git_hooks-0.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quick_git_hooks-0.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file quick_git_hooks-0.1.0.tar.gz.

File metadata

  • Download URL: quick_git_hooks-0.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for quick_git_hooks-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ebd63d1dfd4a5004571af9f3373c8283801b2a062a0d512332bfe27f8523178b
MD5 44ef82226c3c77c6e1dc2e2f6ab0982b
BLAKE2b-256 f70af1ba0adadf753172a9fd91a7bce38d40bc6ecfaa38d5f1c1fde75a78c011

See more details on using hashes here.

File details

Details for the file quick_git_hooks-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for quick_git_hooks-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b185ac0cdf545bebcb3409219199fdb200cd8cb85dc69e313c4a0741b74ef3c
MD5 1a265c462cfea47f425b24c9d4e1cf61
BLAKE2b-256 3c1f21ed7184269c5d77f2406c4caf074f260571e03144358374d11d72f74d45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page