Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep existing copyright lines, use template for default #309

Open
dbwiddis opened this issue Mar 23, 2022 · 2 comments
Open

Keep existing copyright lines, use template for default #309

dbwiddis opened this issue Mar 23, 2022 · 2 comments
Assignees
Labels
in:core MLP core module is:feature New feature todo Accepted items from the backlog which can be worked on

Comments

@dbwiddis
Copy link
Contributor

Software copyright statements are not always as consistent across all files as this plugin assumes, and there is no facility provided to permit different years or different authors other than the few provided substitutions (inception, file creation, latest change).

In order to use this plugin, maintainers are forced to adopt some text that applies to everyone, e.g., "Copyright 2020 the original author or authors" or in one project I maintain, a link to the Github "contributors" page. But in another project I maintain, the convention is for the original author of a file to provide the copyright, e.g., one file might have

Copyright 2012 Author Name

And another file might have

Copyright 2015 Different Author

And perhaps on a third file

Copyright 2012, 2016 Author Name and Different Author

(All with the boilerplate license text surrounding the copyright statement.)

A project which chooses to use the above format/policy has no way to effectively use this plugin. However, there is no need to be so strict. License header templates all use the general format:

  • Stuff
  • Copyright © year(s) owner(s)
  • Other stuff

Currently the plugin has special treatment for the first and last lines, and there's an open PR (#243) to handle middle lines that could, in theory and with a lot of effort, be configured to handle this use case. However, given the commonality across all licence headers (the copyright line is always on its own line) it should be easy to identify just that line using a well known regex (the word Copyright in between carriage returns). The document and the header template could both be tokenized to compare the 3 "stuff" categories shown above, with the following caveat: When no header exists at all, the template would fill in the copyright line; when a header exists containing the word Copyright in between CRs, it would be left completely alone.

I'm willing to submit a PR for this if there is interest.

  1. One solution would be similar to my draft PR Skip if only header difference is copyright first year #286, except instead of just skipping the first year, it would skip the entire line.
  • If no copyright line exists, would specify what to put in, e.g., current year, file creation year/author, etc.
  • If a copyright line exists, would totally ignore it
  1. Another solution would be to add new substitutions (or a prefix before a substitution) for both year(s) and author(s) in which:
  • If no copyright line exists, would specify what to put in, e.g., current year, file creation year/author, etc.
  • If a copyright line exists, would append year(s) and name(s) if needed to existing

Let me know which you'd prefer, if there is interest.

@mathieucarbou
Copy link
Owner

Hi,
I'm always ok for new features and improvements.
This is however a pretty big rewrite, and it will have to be backward compatible, so that's challenging...
But it would definitely help solve several use cases and issues reported, of course.
Thanks 👍

@mathieucarbou mathieucarbou added is:feature New feature in:core MLP core module todo Accepted items from the backlog which can be worked on labels Mar 26, 2022
@dbwiddis
Copy link
Contributor Author

I don't think it's that big. Finding the copyright header is relatively easy and already done in (draft) #323 along with the logic to "skip". You just parse both the file header and license header looking for "copyright" and grab to the end of the line, then swap from the file into the license header before rewriting. It's parameter driven, off by default, and thus compatible.

But the marginal benefit from just skipping any existing header isn't much (if any) for most use cases. The real value is in doing the same steps for the rewrite, very useful for changing license versions (or licenses), changing to slashdot style, etc. while preserving the copyright line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:core MLP core module is:feature New feature todo Accepted items from the backlog which can be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants