-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Replace Placeholders in Licenses #22117
Conversation
Hmm, I'm not sure if it is a good idea to manually overwrite licenses. |
GitLab does already replace the placeholders in Licenses for Years now. And I think, GitLab has Lawyers who say this is not an Issue.
I think the original Author intended this, or else he would not have used Placeholders.
Most people do not edit the License. They just select License foo for the Project and that's all. They expect, everything is done with that and not, that they have to edit the License and remove Placeholders.
I don't think that. Most Forks are just for making PRs. If someone makes a hard Fork, he probably takes a look at the License anyway. |
Gitlab matches more placeholders: PROJECT_TEMPLATE_REGEX =
%r{[\<\{\[]
(project|description|
one\sline\s.+\swhat\sit\sdoes\.) # matching the start and end is enough here
[\>\}\]]}xi.freeze
YEAR_TEMPLATE_REGEX = /[<{\[](year|yyyy)[>}\]]/i.freeze
FULLNAME_TEMPLATE_REGEX =
%r{[\<\{\[]
(fullname|name\sof\s(author|copyright\sowner))
[\>\}\]]}xi.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... I guess licenses tend to be small but this could be significantly improved.
for example if the license does not contain a '<' there is no point doing any of the replacements. So that could be a very simple improvement.
If one were then to use a strings.Replacer, whilst this causes a copy of the bytes to be made, the original []byte could then be used as the basis of a buffer to write into.
However, I'll approve because I think the perf issues here are small enough.
The placeholders do not cover all the cases: [YEAR] Line 3 in 8400146
{YEAR} gitea/options/license/NASA-1.3 Line 45 in 8400146
|
Why not use a regex? You are still missing placeholders.
|
ping ~~~ Personally I think #24354 seems handling more cases and could be covered by tests |
I'm closing this PR in favour of the new one |
Replace #22117. Implement it in a more maintainable way. Some licenses have placeholders e.g. the BSD licenses start with this line: ``` Copyright (c) <year> <owner>. ``` This PR replaces the placeholders with the correct value when initialize a new repo. ### FAQ - Why not use a regex? It will be a pretty complicated regex which could be hard to maintain. - There're still missing placeholders. There are over 500 licenses, it's impossible for anyone to inspect all of them alone. Please help to add them if you find any, and it is also OK to leave them for the future. --------- Co-authored-by: Giteabot <teabot@gitea.io>
Some Licenses have Placeholders e.g. the BSD Licenses start with this line:
This PR replaces the placeholders with the correct value, when creating a new Repo. Tested with the BSD, GPL, AGPL and MIT Licenses, which are the most used.