10000 GitHub - ultralytics/pre-commit: Ultralytics pre-commit hooks
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ultralytics/pre-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Ultralytics logo

๐Ÿ› ๏ธ Ultralytics Pre-commit Hooks

Welcome to the Ultralytics pre-commit hooks repository! This collection features hooks developed by Ultralytics 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 itself on their official website.

Ultralytics Actions Ultralytics Discord Ultralytics Forums Ultralytics Reddit

๐Ÿ—‚๏ธ Repository Structure

This repository is organized for clarity and ease of use:

  • hooks/ directory: Contains individual Python scripts, each representing a distinct pre-commit hook designed for specific checks or code formatting tasks.
  • .pre-commit-hooks.yaml: The root configuration file defining the available hooks, making them discoverable and easy to integrate into your projects.

Hook Scripts in hooks Directory ๐Ÿ“‚

Each script within the hooks directory is a standalone Python program performing a specific pre-commit task. For instance:

  • capitalize_comments.py: Ensures that standalone inline comments start with a capital letter, promoting readability and a professional coding style.

Defining Hooks in .pre-commit-hooks.yaml ๐Ÿ“˜

The .pre-commit-hooks.yaml file lists all installable hooks. Here's an example structure for a hook definition:

- id: hook-id # Unique identifier for the hook
  name: "A descriptive name for the hook" # User-friendly name
  entry: hooks/your_hook_script.py # Path to the hook script
  language: python # Specifies the language the script is written in
  types: [python] # File types the hook should run on

โž• Adding New Hooks

Interested in contributing a new hook? Follow these steps:

  1. 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.
  2. Declare the Hook: Add a new entry for your hook in the .pre-commit-hooks.yaml file, following the structure shown above.
  3. 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.
  4. Submit Your Contribution: Commit your changes and create a Pull Request to the repository. Adhering to our contribution guidelines is appreciated.

๐Ÿ”ง Installing Hooks in Your Project

To use Ultralytics pre-commit hooks in your own project, add the following to your project's .pre-commit-config.yaml file:

repos:
  - repo: https://github.com/ultralytics/pre-commit-hooks
    rev: main # Pin to 'main' for the latest, or a specific git tag/commit SHA for stability
    hooks:
      - id: capitalize-comments # Example: Use the ID of the hook you want to include
      # Add other hook IDs as needed

After updating your configuration, run this command in your project's root directory to install the hooks:

pre-commit install

Now, 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) process.

๐Ÿ’ก Contribute

Ultralytics values community contributions! Your involvement helps us improve and grow. Please review our Contributing Guide for detailed information on how to participate. We also encourage you to share your feedback through our Survey. A big thank you ๐Ÿ™ to all our contributors! Check out some tips on contributing to open-source projects on our blog.

Ultralytics open-source contributors

๐Ÿ“„ License

Ultralytics offers two licensing options:

  • AGPL-3.0 License: An OSI-approved open-source license ideal for students, researchers, and enthusiasts who value open collaboration. See the LICENSE file for details.
  • 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.

๐Ÿ“ฎ Contact

For bug reports or feature requests related to Ultralytics pre-commit hooks, please submit an issue on GitHub Issues. For general questions and discussions, join our vibrant community on Discord!


Ultralytics GitHub space Ultralytics LinkedIn space Ultralytics Twitter space Ultralytics YouTube space Ultralytics TikTok space Ultralytics BiliBili space Ultralytics Discord
0