diff --git a/README.md b/README.md index 7decbe311b..b226d74ac4 100644 --- a/README.md +++ b/README.md @@ -99,13 +99,6 @@ check out our [documentation](https://docs.all-hands.dev/modules/usage/getting-s There you'll find resources on how to use different LLM providers, troubleshooting resources, and advanced configuration options. -### Custom Scripts - -OpenHands supports custom scripts that run at different points in the runtime lifecycle: - -- **setup.sh**: Place this script in the `.openhands` directory of your repository to run custom setup commands when the runtime initializes. -- **pre-commit.sh**: Place this script in the `.openhands` directory to add a custom git pre-commit hook that runs before each commit. This can be used to enforce code quality standards, run tests, or perform other checks before allowing commits. - ## 🤝 How to Join the Community OpenHands is a community-driven project, and we welcome contributions from everyone. We do most of our communication diff --git a/docs/modules/usage/customization/repository.md b/docs/modules/usage/customization/repository.md index 62306632eb..1edf199537 100644 --- a/docs/modules/usage/customization/repository.md +++ b/docs/modules/usage/customization/repository.md @@ -21,3 +21,27 @@ sudo apt-get update sudo apt-get install -y lsof cd frontend && npm install ; cd .. ``` + +## Pre-commit Script +You can add a `.openhands/pre-commit.sh` file to create a custom git pre-commit hook that runs before each commit. +This can be used to enforce code quality standards, run tests, or perform other checks before allowing commits. + +For example: +```bash +#!/bin/bash +# Run linting checks +cd frontend && npm run lint +if [ $? -ne 0 ]; then + echo "Frontend linting failed. Please fix the issues before committing." + exit 1 +fi + +# Run tests +cd backend && pytest tests/unit +if [ $? -ne 0 ]; then + echo "Backend tests failed. Please fix the issues before committing." + exit 1 +fi + +exit 0 +```