Lucas-C / pre-commit-hooks

git pre-commit hooks
http://pre-commit.com/hooks.html
MIT License
117 stars 51 forks source link

How to handle different sets of copyright holder lines? #101

Open peterjc opened 1 month ago

peterjc commented 1 month ago

How do you suggest handling different lists of copyright holders and/or dates in different files? For example, suppose the main LICENSE and template tries to capture the union of all contributors - an example based on that from #64:

 Copyright © 2023-2024 John Doe <john@example.com>
 Copyright © 2020-2022 Steve Luamo <steve@luamo.com>
 Copyright © 2015-2022 Leve Stuamo <leve@stuamo.com>

Some of the project files might match the above perfectly - the easy case. However, the project might have some new code files just by John:

 Copyright © 2023-2024 John Doe <john@example.com>

But there could be some static files which John has not edited which are only copyright by the original team, e.g.

 Copyright © 2015-2017 Leve Stuamo <leve@stuamo.com>

Leaving aside #64 on which lines if any need updating with --use-current-year, is there anyway to handle this gracefully in this hook?

peterjc commented 1 month ago

I can think of a partial workaround based on excluding multiple copyright holder lines from the license block being checked - leaving none, or a single umbrella entry.

For example, if all the contributors work for the same employer, that body is likely the actual copyright holder and you just have date-variants of Copyright © 2023-2024 The Company to worry about.

This idea also works if you can name the contributors collectively from the point of view of the license header (perhaps supplemented by a list of names and dates above/below the automatically checked license block), e.g. Copyright © 2023-2024 The Project Contributors.

If there are just a couple of named entities involved, you might be able to solve this with multiple license templates (e.g. one file with Copyright © 2015-2022 The Start-Up Company, one file with Copyright © 2023-2024 John Doe Sole-Trader, and one file with both). This won't scale though.

If this use-case is common, perhaps we need some kind of <AUTHOR-LINE> or <COPYRIGHT-HOLDER> wildcard within the license block template?