-
Notifications
You must be signed in to change notification settings - Fork 62
New feature: replace already existing license header based on pattern #98
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
Conversation
CI fails, please fix. |
Hi @wu-sheng, |
@halacs It is due to the fact that you're a newcomer to this repository, CI will be automatically run in your next contribution after this merges. :) |
@Superskyyy I see :) I extended the tests a bit but I'm finished for sure now. |
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.
Hi @halacs , thanks! I prefer to add a CLI option in license-eye header fix
such as --replace
or similar names, so that when users don't have a pattern configured they can keep the original file headers to avoid too many changes, what do you think?
Hi @kezhenxu94, actually my change won't cause more file changes. My code just avoid duplicated headers. The way how we decide if a file needs to be updated remained the same. If a file header needs to be added, I check if there is an old header we need to remove first right before the new header would be added. Or maybe I don't understand something about the |
Hi, @halacs , the config |
Hi @kezhenxu94 ,
This means is expected license header is there file won't be updated so If I'm wrong please share where |
Can you show me a case of the duplicated headers, I think that should not happen. If I understand correctly, this PR is to fix the problem above? Here is what I think: if the previous header satisfies the // Remove previous license header version to allow update it
if licensePattern != nil {
content = licensePattern.ReplaceAll(content, []byte(""))
} |
hi @kezhenxu94, This PR is to make license update easier. Think of the case when a few words, such as year range (e.g. 2016-2022) needs to be updated (e.g. to 2016-2023). We need to detect there is the license already but it is outdated so needs to be removed first. In this case Until However, if By the way, |
Hi @halacs thanks for elaborating, that totally makes sense to me now.
This must be bug when I was reorganizing the configurations, can you please also update the codes below to - pattern := config.Pattern
+ pattern := config.License.Pattern and remove the unused Thanks!!! I think the goal of this PR is clear now and I can merge it |
Hi @kezhenxu94, I just added the change you requested. I could run the Thanks for your effort! |
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.
LGTM, thank you @halacs for the patience and explanation of the use case
Example config snippet: