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

Support flexible years in licenses (#23) #59

Merged
merged 1 commit into from
Jan 22, 2023

Conversation

aostrowski
Copy link
Contributor

The new flag --flexible-years allows automatically updating the year in copyright headers, using always the current year when inserting new ones and removing headers regardless of the years they contain.

Copy link
Owner

@Lucas-C Lucas-C left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!
This would make a useful addition to this hook 😊
Could you please also provide a usage example in the README.md as part of this PR?

pre_commit_hooks/insert_license.py Outdated Show resolved Hide resolved
pre_commit_hooks/insert_license.py Outdated Show resolved Hide resolved
tests/insert_license_test.py Outdated Show resolved Hide resolved
# Strict and flexible years
('module_with_stale_year_in_license.py', '#', False, None, False, False),
('module_with_stale_year_range_in_license.py', '#', False, None, False, False),
('module_with_license.py', '#', False, 'module_without_license.py', True, True),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same suggestion here: could you add a test with a badly formatted year range please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

pre_commit_hooks/insert_license.py Outdated Show resolved Hide resolved
The new flag `--use-current-year` allows automatically updating the year
in copyright headers, using always the current year when inserting new
ones and removing headers regardless of the years they contain.
@aostrowski
Copy link
Contributor Author

Could you please also provide a usage example in the README.md as part of this PR?
Done.

Thanks for the review, I like the code better now.

@@ -84,6 +85,20 @@ In case you want to remove the comment headers introduced by
3. Remove the `--remove-header` arg and update your `LICENSE.txt` ;
4. Re-run the hook on all your files.

#### Handling years flexibly

You can add `--use-current-year` to change how the hook treats years in the
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

@Lucas-C
Copy link
Owner

Lucas-C commented Jan 22, 2023

Merging this now!
Thank you for your contribution @aostrowski.
I'm goinf to perform a new release with this new handy feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants