Lucas-C / pre-commit-hooks

git pre-commit hooks

Home Page:http://pre-commit.com/hooks.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using pre-commit to insert a license header

coreyackland opened this issue · comments

Objective is to add a license to each new file staged with pre-commit.

I've created a .pre-commit-config.yaml file with the following:

repos:

  # license header
  - repo: https://github.com/Lucas-C/pre-commit-hooks
    rev: v1.1.12
    hooks:
      - id: insert-license
        name: "Insert license header in C++ source files"
        args: [--license-filepath=util/header.txt,
               '--comment-style=/*| *| */',
               --detect-license-in-X-top-lines=16]
        types_or: [c, c++, objective-c]

The git repo has pre-commit 'installed', created a new file, staged it, ran pre-commit and results return with:

Insert license header in C++ source files............(no files to check)Skipped

What else might I need to add for the hook script to find the files to add the license header?

Thanks

Hi @coreyackland

I have just checked this hook behaviour on .h / .cpp files, using the configuration you provided, and it works fine.

We even have unit tests for .cpp files: https://github.com/Lucas-C/pre-commit-hooks/blob/master/tests/insert_license_test.py#L47

Are your C++ files versioned under git?
What are your versions of python and pre-commit?

No answer: closing this for now