Comments (6)
I put this in place because I assumed if multiple people are present in the header, only the one who made changes should have the year updated.
I tried to find real-world examples of files with multiple numbers in license headers. In most cases, I guess the correct behavior would be to update just the last spotted year, for instance like in those cases: https://github.com/torvalds/linux/blob/master/include/misc/altera.h, https://github.com/torvalds/linux/blob/master/include/video/sa1100fb.h.
In the first case, other companies were developing the header earlier on, so their copyrights shouldn't be extended when other developers build on their work. In the second case, an LCD controller have 4 digits in the name, which would be treated as a year instead of the actual copyright year.
I can modify the code to treat all numbers as years, or I can treat just the last one. A third option would be to just update the year on lines containing the word "Copyright". Perhaps this would be the best option.
Which approach do you think would work in most cases?
from pre-commit-hooks.
Ping @aostrowski who implemented this
As for myself, I'd be open to perform the changes on all matching lines in the header
from pre-commit-hooks.
Thanks for the fast reply
I think finding an approach that works for everything is hard. In our case we do need support for updating multiple ranges. There are two options I can think of:
- add another argument to select whether to update the first/last/all years (or ranges)
- find a way to annotate years in the input license file that need updating, would also fix the LCD controller issue. Either some placeholder for "insert current year" or a way to mark "this is a year" - if neither is found revert to current behavior.
I understand if these are too intrusive for your taste, and adding the changes in our own fork wouldn't be terribly hard.
from pre-commit-hooks.
Thank you both for your thoughts on the subject.
I think --use-current-year --update-all-year-ranges
could be a simple solution that should please everyone.
Are you OK with that solution?
Is one of you interested in contributing a PR for this?
from pre-commit-hooks.
--update-all-year-ranges
would work well --update-all-year-ranges
is given.
I can take a stab at a PR for this, might just take a few days before I can find the time.
from pre-commit-hooks.
I can take a stab at a PR for this, might just take a few days before I can find the time.
Great! Sure, take your time
from pre-commit-hooks.
Related Issues (20)
- Consider changing the output of `insert-license` to only mention what the script did, instead of instructing the user or mentioning what pre-commit will do HOT 2
- Using pre-commit to insert a license header HOT 2
- Tabs are replaced in this binary string HOT 3
- Avoid space insertion when inserting licence HOT 7
- Failing test test_badopt HOT 6
- Dropped py2 in patch version? HOT 2
- Add LICENSE after "file header" for php HOT 1
- insert_license - write file back in original encoding HOT 3
- Newline is forced between license comment and code HOT 2
- split commit hooks for less dependencies
- insert-license hook ignores top-level files selected by `types` or `types_or` HOT 2
- add ignore-files argument to remove-crlf? HOT 2
- python-Levenshtein-wheels not available for python 3.10 HOT 6
- Possible incorrect formatting from remove tabs HOT 13
- insert_license - Inserting new license with --use-current-year replaces start years in ranges HOT 3
- Matching multiple license headers? HOT 8
- Rename this repo? HOT 3
- insert-license should not add a LF at the end of the license header file if it does not have one, to prevent an ugly empty separator line HOT 2
- Ignore commit amend message files in .git when running forbid-tabs & co by default HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pre-commit-hooks.