{"id":19454120,"url":"https://github.com/ultralytics/pre-commit","last_synced_at":"2025-04-25T04:31:04.666Z","repository":{"id":199969476,"uuid":"704212988","full_name":"ultralytics/pre-commit","owner":"ultralytics","description":"Ultralytics pre-commit hooks","archived":false,"fork":false,"pushed_at":"2025-03-28T01:53:39.000Z","size":54,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T02:39:48.720Z","etag":null,"topics":["hooks","hub","pre-commit","ultralytics","yolo"],"latest_commit_sha":null,"homepage":"https://ultralytics.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ultralytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"glenn-jocher","patreon":"ultralytics","open_collective":"ultralytics"}},"created_at":"2023-10-12T19:23:05.000Z","updated_at":"2025-03-28T01:53:41.000Z","dependencies_parsed_at":"2023-12-10T00:20:34.856Z","dependency_job_id":"9e2ee83e-791d-428f-a158-2fd4e107e611","html_url":"https://github.com/ultralytics/pre-commit","commit_stats":null,"previous_names":["ultralytics/pre-commit"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultralytics%2Fpre-commit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultralytics%2Fpre-commit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultralytics%2Fpre-commit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultralytics%2Fpre-commit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ultralytics","download_url":"https://codeload.github.com/ultralytics/pre-commit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250754659,"owners_count":21481850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hooks","hub","pre-commit","ultralytics","yolo"],"created_at":"2024-11-10T17:08:01.083Z","updated_at":"2025-04-25T04:31:04.657Z","avatar_url":"https://github.com/ultralytics.png","language":"Python","funding_links":["https://github.com/sponsors/glenn-jocher","https://patreon.com/ultralytics","https://opencollective.com/ultralytics"],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.ultralytics.com/\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/ultralytics/assets/main/logo/Ultralytics_Logotype_Original.svg\" width=\"320\" alt=\"Ultralytics logo\"\u003e\u003c/a\u003e\n\n# 🛠️ Ultralytics Pre-commit Hooks\n\nWelcome to the Ultralytics pre-commit hooks repository! This collection features hooks developed by [Ultralytics](https://www.ultralytics.com/) to enforce code quality and maintain consistent standards across our software projects. Integrating these hooks into your development workflow automates code validation, ensuring a high level of code hygiene and reducing manual review efforts. Learn more about the [pre-commit framework](https://pre-commit.com/) itself on their official website.\n\n[![Ultralytics Actions](https://github.com/ultralytics/pre-commit/actions/workflows/format.yml/badge.svg)](https://github.com/ultralytics/pre-commit/actions/workflows/format.yml)\n[![Ultralytics Discord](https://img.shields.io/discord/1089800235347353640?logo=discord\u0026logoColor=white\u0026label=Discord\u0026color=blue)](https://discord.com/invite/ultralytics)\n[![Ultralytics Forums](https://img.shields.io/discourse/users?server=https%3A%2F%2Fcommunity.ultralytics.com\u0026logo=discourse\u0026label=Forums\u0026color=blue)](https://community.ultralytics.com/)\n[![Ultralytics Reddit](https://img.shields.io/reddit/subreddit-subscribers/ultralytics?style=flat\u0026logo=reddit\u0026logoColor=white\u0026label=Reddit\u0026color=blue)](https://reddit.com/r/ultralytics)\n\n## 🗂️ Repository Structure\n\nThis repository is organized for clarity and ease of use:\n\n- **`hooks/` directory:** Contains individual [Python](https://www.python.org/) scripts, each representing a distinct pre-commit hook designed for specific checks or code formatting tasks.\n- **`.pre-commit-hooks.yaml`:** The root configuration file defining the available hooks, making them discoverable and easy to integrate into your projects.\n\n### Hook Scripts in `hooks` Directory 📂\n\nEach script within the `hooks` directory is a standalone Python program performing a specific pre-commit task. For instance:\n\n- `capitalize_comments.py`: Ensures that standalone inline comments start with a capital letter, promoting readability and a professional coding style.\n\n### Defining Hooks in `.pre-commit-hooks.yaml` 📘\n\nThe `.pre-commit-hooks.yaml` file lists all installable hooks. Here's an example structure for a hook definition:\n\n```yaml\n- id: hook-id # Unique identifier for the hook\n  name: \"A descriptive name for the hook\" # User-friendly name\n  entry: hooks/your_hook_script.py # Path to the hook script\n  language: python # Specifies the language the script is written in\n  types: [python] # File types the hook should run on\n```\n\n## ➕ Adding New Hooks\n\nInterested in contributing a new hook? Follow these steps:\n\n1.  **Create Your Hook Script:** Develop a Python script implementing your desired check or formatting logic. Place it in the `hooks/` directory. Ensure your script includes clear error messages and handles potential edge cases.\n2.  **Declare the Hook:** Add a new entry for your hook in the `.pre-commit-hooks.yaml` file, following the structure shown above.\n3.  **Test Locally:** Thoroughly test your hook in a local project environment using `pre-commit run --all-files` to confirm it works as expected before submitting.\n4.  **Submit Your Contribution:** Commit your changes and create a Pull Request to the repository. Adhering to our [contribution guidelines](https://docs.ultralytics.com/help/contributing/) is appreciated.\n\n## 🔧 Installing Hooks in Your Project\n\nTo use Ultralytics pre-commit hooks in your own project, add the following to your project's `.pre-commit-config.yaml` file:\n\n```yaml\nrepos:\n  - repo: https://github.com/ultralytics/pre-commit-hooks\n    rev: main # Pin to 'main' for the latest, or a specific git tag/commit SHA for stability\n    hooks:\n      - id: capitalize-comments # Example: Use the ID of the hook you want to include\n      # Add other hook IDs as needed\n```\n\nAfter updating your configuration, run this command in your project's root directory to install the hooks:\n\n```bash\npre-commit install\n```\n\nNow, the specified Ultralytics hooks will automatically run on your staged files each time you commit, helping maintain code quality effortlessly as part of your [Continuous Integration (CI)](https://www.ultralytics.com/glossary/continuous-integration-ci) process.\n\n## 💡 Contribute\n\nUltralytics values community contributions! Your involvement helps us improve and grow. Please review our [Contributing Guide](https://docs.ultralytics.com/help/contributing/) for detailed information on how to participate. We also encourage you to share your feedback through our [Survey](https://www.ultralytics.com/survey?utm_source=github\u0026utm_medium=social\u0026utm_campaign=Survey). A big thank you 🙏 to all our contributors! Check out some [tips on contributing to open-source projects](https://www.ultralytics.com/blog/tips-to-start-contributing-to-ultralytics-open-source-projects) on our blog.\n\n[![Ultralytics open-source contributors](https://raw.githubusercontent.com/ultralytics/assets/main/im/image-contributors.png)](https://github.com/ultralytics/ultralytics/graphs/contributors)\n\n## 📄 License\n\nUltralytics offers two licensing options:\n\n- **AGPL-3.0 License:** An [OSI-approved](https://opensource.org/license/agpl-v3) open-source license ideal for students, researchers, and enthusiasts who value open collaboration. See the [LICENSE](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) file for details.\n- **Enterprise License:** Designed for commercial use, this license allows seamless integration of Ultralytics software and AI models into commercial products and services, bypassing the open-source requirements of AGPL-3.0. For inquiries, visit [Ultralytics Licensing](https://www.ultralytics.com/license).\n\n## 📮 Contact\n\nFor bug reports or feature requests related to Ultralytics pre-commit hooks, please submit an issue on [GitHub Issues](https://github.com/ultralytics/pre-commit/issues). For general questions and discussions, join our vibrant community on [Discord](https://discord.com/invite/ultralytics)!\n\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/ultralytics\"\u003e\u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-social-github.png\" width=\"3%\" alt=\"Ultralytics GitHub\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png\" width=\"3%\" alt=\"space\"\u003e\n  \u003ca href=\"https://www.linkedin.com/company/ultralytics/\"\u003e\u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-social-linkedin.png\" width=\"3%\" alt=\"Ultralytics LinkedIn\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png\" width=\"3%\" alt=\"space\"\u003e\n  \u003ca href=\"https://twitter.com/ultralytics\"\u003e\u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-social-twitter.png\" width=\"3%\" alt=\"Ultralytics Twitter\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png\" width=\"3%\" alt=\"space\"\u003e\n  \u003ca href=\"https://youtube.com/ultralytics\"\u003e\u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-social-youtube.png\" width=\"3%\" alt=\"Ultralytics YouTube\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png\" width=\"3%\" alt=\"space\"\u003e\n  \u003ca href=\"https://www.tiktok.com/@ultralytics\"\u003e\u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-social-tiktok.png\" width=\"3%\" alt=\"Ultralytics TikTok\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png\" width=\"3%\" alt=\"space\"\u003e\n  \u003ca href=\"https://ultralytics.com/bilibili\"\u003e\u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-social-bilibili.png\" width=\"3%\" alt=\"Ultralytics BiliBili\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-transparent.png\" width=\"3%\" alt=\"space\"\u003e\n  \u003ca href=\"https://discord.com/invite/ultralytics\"\u003e\u003cimg src=\"https://github.com/ultralytics/assets/raw/main/social/logo-social-discord.png\" width=\"3%\" alt=\"Ultralytics Discord\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultralytics%2Fpre-commit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fultralytics%2Fpre-commit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultralytics%2Fpre-commit/lists"}