From a0487c568d898123396ee2bc57e46f77f9348978 Mon Sep 17 00:00:00 2001 From: Tomeshwari-02 Date: Thu, 5 Feb 2026 23:33:19 +0530 Subject: [PATCH] Enhance CONTRIBUTING.md with pre-commit instructions Added a comprehensive pre-commit setup guide to ensure code quality and consistency. --- CONTRIBUTING.md | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 06f9d935..c73184e8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,3 +43,113 @@ Update [CHANGELOG.md](CHANGELOG.md) to mint a new release from `main`, then `git tag` with [CalVer](https://calver.org/) (format `YYYY.MM.MINOR`). Then invoke C4 to deploy on the server in itself. + +## 🚀 Contributing Guide – Pre-commit Setup + +To keep the codebase clean and maintain high-quality standards, this project uses **pre-commit hooks**. +These hooks automatically check your code before it is committed, ensuring it follows formatting, linting, and style rules. + +--- + +## ❓ Why Do We Use Pre-commit? + +Pre-commit helps to: + +- ✅ Maintain consistent code style across all contributions +- ✅ Automatically fix formatting and linting issues +- ✅ Reduce CI failures caused by code quality checks +- ✅ Save reviewer time by catching errors early +- ✅ Make sure your first PR does not get blocked by CI linting + +Without pre-commit, your Pull Request might fail automated checks, and you will need to fix and push changes again. + +--- + +## ⚙️ Installing Pre-commit + +Follow these steps before making your first contribution. + +### 1️⃣ Install Pre-commit + +Make sure you have Python installed, then run: + + +`pip install pre-commit` + + +### 2️⃣ Install Project Hooks + +After cloning the repository, run: + +`pre-commit install` + +This command installs the hooks locally so they run automatically before each commit. + +---------- + +### 3️⃣ Run Pre-commit Manually (Optional but Recommended) + +You can test everything before committing: + +`pre-commit run --all-files` + +This will check and fix issues across the project. + +---------- + +## 🔄 Workflow with Pre-commit + +Your contribution workflow should look like this: + +1. Fork the repository + +2. Clone your fork locally + +3. Install pre-commit hooks + +4. Make your changes + +5. Commit normally + +6. Push and create a Pull Request + + +If pre-commit finds issues, it will automatically fix them or show errors that must be corrected before committing. + +---------- + +## 🛠️ Fixing Pre-commit Errors + +If pre-commit blocks your commit: + +### Step 1: Review Errors + +Check the errors shown in your terminal. + +### Step 2: Fix or Stage Auto-fixed Files + +`git add .` + +### Step 3: Commit Again + +`git commit -m "Fix linting issues"` + +---------- + +## 📚 Contribution Resources + +Please also check our full contribution guidelines: + +👉 [https://github.com/UrLab/DocHub#contribute-](https://github.com/UrLab/DocHub#contribute-) + +---------- + +## 💡 Tips for New Contributors + +- Always run pre-commit before pushing code + +- Keep commits small and focused + +- Read CI error messages carefully if your PR fails + +- Do not hesitate to ask maintainers for help