oracle-ai-developer-hub

Pre-commit Setup Guide

This repository uses pre-commit hooks to automatically format code on every commit.

Formatters Used

Initial Setup

  1. Install dependencies (if not already installed):

    pip install -r requirements-dev.txt 

    Or install individually:

    pip install pre-commit ruff 
  2. Install pre-commit hooks:

    pre-commit install 

    This will set up the git hooks to run automatically on every commit.

  3. Optional: Run on all files (to format existing code):

    pre-commit run --all-files 

How It Works

Once installed, pre-commit will automatically:

Manual Usage

You can also run the formatters manually:

# Run all hooks on staged files pre-commit run # Run all hooks on all files pre-commit run --all-files # Run a specific hook pre-commit run ruff --all-files pre-commit run prettier --all-files 

Configuration Files

Updating Hooks

To update pre-commit hooks to their latest versions:

pre-commit autoupdate 

Troubleshooting

If hooks fail, you can:

  1. Skip hooks for a specific commit (not recommended):

    git commit --no-verify 
  2. Update hook versions:

    pre-commit autoupdate 
  3. Clear pre-commit cache:

    pre-commit clean