Comments (6)
addlicense does not modify files when the copyright year changes
That's by design. More generally, the program doesn't touch a file if it already contains a license. See the help text:
Lines 35 to 39 in c6b7f1e
check whether the license text + copyright holder + year is actually present
At the moment it simply searches for "copyright" substring in
Line 220 in c6b7f1e
Suppose we add such check. What would be your expectation: that the program replaces present year(s) and holder(s) or adds them alongside existing entries? From "... not possible to switch to a new license" it seems like the former but from this issue title I'm guessing it's the latter?
Also, it's very common for a project to contain "vendored" or "third party" packages, typically containing different years, holders or even the license. When addlicense
is run on a directory, it checks all source code regardless, which in this case would wipe everyone else's copyrights.
bump the copyright year
That sounds weird. I don't believe it's how licensing works. You might want to add a new year to a list instead of replacing it. What happens to the copiright of the previous year if you just "bump" it? Also, you typically never "bump" anything in the license headers in the source code files and use the a separate LICENSE file. See this very project for an example.
not possible to switch to a new license
As of this writing, the program bundles 3 licenses in https://github.com/google/addlicense/blob/c6b7f1e7f34a650f11d8767927d91e03bf32c5aa/tmpl.go - Apache 2, BSD and MIT. They all are just Go templates which the execution output of is simply insterted near the top of a file.
"Switching" to a new license, or in other words replacing license header with a new one would require some kind of license begin/end marks, I imagine, or some other sort of deterministic parser. Unless I misunderstood. The feature proposal isn't very clear tbh.
Feels like this would add a lot of complexity to the program. "Switching" to another license sounds like a big move. Most projects never change their license. Happens very rarely, once in a lifetime of a project maybe. Is the added complexity really worth it?
from addlicense.
In other words, a license header isn't structured. It contains arbitrary user input strings.
How would you implement a "license replacement" feature?
from addlicense.
check whether the license text + copyright holder + year is actually present
At the moment it simply searches for "copyright" substring in
Line 220 in c6b7f1e
and assumes a license header is present if found.Suppose we add such check. What would be your expectation: that the program replaces present year(s) and holder(s) or adds them alongside existing entries? From "... not possible to switch to a new license" it seems like the former but from this issue title I'm guessing it's the latter?
Well, initially I just wanted to bump the copyright year in all source files, so my expectation would be that if I provide a new year and/or copyright holder, that the old one will be replaced.
Also, it's very common for a project to contain "vendored" or "third party" packages, typically containing different years, holders or even the license. When
addlicense
is run on a directory, it checks all source code regardless, which in this case would wipe everyone else's copyrights.
There's an (imho) relatively nice workaround for that:
$ addlicense $(fd -E vendor/**/* . '.*\.c')
bump the copyright year
That sounds weird. I don't believe it's how licensing works. You might want to add a new year to a list instead of replacing it. What happens to the copiright of the previous year if you just "bump" it? Also, you typically never "bump" anything in the license headers in the source code files and use the a separate LICENSE file. See this very project for an example.
not possible to switch to a new license
As of this writing, the program bundles 3 licenses in https://github.com/google/addlicense/blob/c6b7f1e7f34a650f11d8767927d91e03bf32c5aa/tmpl.go - Apache 2, BSD and MIT. They all are just Go templates which the execution output of is simply insterted near the top of a file.
"Switching" to a new license, or in other words replacing license header with a new one would require some kind of license begin/end marks, I imagine, or some other sort of deterministic parser. Unless I misunderstood. The feature proposal isn't very clear tbh.
Feels like this would add a lot of complexity to the program. "Switching" to another license sounds like a big move. Most projects never change their license. Happens very rarely, once in a lifetime of a project maybe. Is the added complexity really worth it?
I agree, implementing switching to a new license is probably not worth it. However replacing the copyright year and/or the copyright holder could be in principle doable? Because then addlicense could be used to enforce that the copyright headers in all relevant source files are up to date.
from addlicense.
enforce that the copyright headers in all relevant source files are up to date
There's nothing to keep "up to date" really. You put the header once and that's it. Unless I misunderstand what this is about.
from addlicense.
Anyway, to implement a header replacement I guess a simple way would be to take all lines from 0 or 1 if it contains hashBang until first empty or non-comment line.
Not sure how well it would work. Other ideas?
from addlicense.
I don't think it makes sense to alter existing licenses. Something that's copyrighted 2019 is always copyrighted that year (although you might want to add additional years). Even if it made sense to change an existing license, it would open up a can of worms as x1ddos noted above (restricting scope to avoid inadvertently changing unintended files, non-deterministic parsing semantics of existing licenses, etc.).
Btw, the suggested work around:
$ addlicense $(fd -E vendor/**/* . '.*.c')
Solves one problem (go vendored src) but there are many other ways to inherit source files with embedded licenses. Also, I'd worry about someone who doesn't realize they need to filter out inherited artifacts and doesn't know to use a construct like that.
Given the above, I'm going to close this issue.
from addlicense.
Related Issues (20)
- use GoReleaser to build and push container images HOT 6
- use go-enry to identify generated, vendored and other types of code
- Ignore subdirectories pattern HOT 9
- Support adding license header in .txt, .patch and .tmpl files HOT 5
- Ignore doesn't work without equals sign HOT 2
- Using `//` comments for C++ header files
- malformed module path "io/fs" HOT 2
- Intermittent failure
- Include basic example of running for the first time. HOT 1
- [Proposal] Usage as module instead of CLI HOT 3
- Can a new tag be added? HOT 1
- Introduce a flag to prefer `//` over `/*...*/` HOT 1
- Copyright line should append after the SPDX identifier HOT 3
- An extra whitespace indentation for the Apache License template
- Recursive check pattern HOT 1
- (Provide option to) ignore empty files
- Feature Request: Add a version subcommand HOT 1
- Bug: Files generated by stringer are skipped HOT 4
- How to install? `go get` is deprecated
- provide fail-on-diff flag to enable checking licence headers HOT 5
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 addlicense.