leoll2 / copyright_notice_precommit

pre-commit hook to verify the presence of a copyright notice in your files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

copyright-notice-precommit

GitHub PyPI - Python Version Build Status codecov pre-commit.ci status Code quality: Inspector Code style: black

This is a pre-commit hook to make sure you don't forget adding the copyright notice when committing a (new) file.

Usage

If you haven't installed pre-commit yet, please follow the instructions in the official website.

To install this hook, add the following to your .pre-commit-config.yaml:

-   repo: https://github.com/leoll2/copyright_notice_precommit
    rev: latest
    hooks:
    -   id: copyright-notice
        args: [--notice=copyright.txt]

with --notice pointing to a template file containing the copyright to match.

Note: the template file must contain exclusively the copyright notice as text. It's recommended not to insert extra spaces or linebreaks at the beginning and end of the file.

Example

Let's assume this is your copyright notice template file:

# Copyright (C) ACME Inc - All Rights Reserved

Then, this file will pass the pre-commit check:

#!/usr/bin/env python

# Copyright (C) ACME Inc - All Rights Reserved

print("hello world")

Conversely, this one shall NOT pass (due to missing notice):

#!/usr/bin/env python

print("hello world")

License

This hook is released under the MIT License.

Contributing

Do you want to report a bug? Would you like to see new features? Feel free to open an issue or a pull request. All contributions are welcome!

About

pre-commit hook to verify the presence of a copyright notice in your files

License:MIT License


Languages

Language:Python 100.0%