google / addlicense

A program which ensures source code files have copyright license headers by scanning directory patterns recursively
Apache License 2.0
724 stars 169 forks source link

feat: Add pre-commit.com hook config to allow easy usage with pre-commit configs #143

Open rickeylev opened 1 year ago

rickeylev commented 1 year ago

This allows easily using addlicense with pre-commit.com hook configs to automatically run when committing.

An example example .pre-commit-config.yaml for a user would look like:

- repo: https://github.com/google/addlicense
    rev: <git tag>
    hooks:
      - id: addlicense
        args: [-l, apache, -c, "Copyright Owner"]

And under the hood, pre-commit will go install the addlicense program and run it on the affected files with the specified args.

Spill-Tea commented 5 months ago

I was just going to create a pull request for the same thing. It would be nice to be able to use addlicense repo as a pre-commit hook, instead of creating a mirror fork to maintain independently. Right now, I am just hacking things and injecting my own .pre-commit-hooks.yaml file on the downloaded source after installing with pre-commit to at least support locally.