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

Update header #987

Merged
merged 19 commits into from
Feb 26, 2024
Merged

Update header #987

merged 19 commits into from
Feb 26, 2024

Conversation

bjoernricks
Copy link
Contributor

@bjoernricks bjoernricks commented Feb 23, 2024

What

Improve pontos-update-header CLI

Why

Currently it's not possible to overwrite the company in copyright headers if it doesn't fit to Greenbone.

References

DOS-175

Checklist

  • Tests

Copy link

github-actions bot commented Feb 23, 2024

Conventional Commits Report

Type Number
Bug Fixes 1
Changed 6
Added 3

🚀 Conventional commits found.

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 95.12195% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 90.37%. Comparing base (0bf1bac) to head (b5ae3ab).

❗ Current head b5ae3ab differs from pull request most recent head 2a394c3. Consider uploading reports for the commit 2a394c3 to get more accurate results

Files Patch % Lines
pontos/updateheader/updateheader.py 94.87% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #987      +/-   ##
==========================================
+ Coverage   90.21%   90.37%   +0.15%     
==========================================
  Files         103      103              
  Lines        6961     6958       -3     
  Branches      986      986              
==========================================
+ Hits         6280     6288       +8     
+ Misses        479      471       -8     
+ Partials      202      199       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bjoernricks bjoernricks marked this pull request as ready for review February 23, 2024 13:00
@bjoernricks bjoernricks requested a review from a team as a code owner February 23, 2024 13:00
@bjoernricks bjoernricks added the make release To trigger GitHub release action. label Feb 23, 2024
@bjoernricks bjoernricks enabled auto-merge (rebase) February 23, 2024 13:01
@bjoernricks bjoernricks requested a review from y0urself February 26, 2024 07:43
Extend temp_file context manager to support also creating binary files.
Split the tests into separate test cases for each function and use
context managers for creating temporary directories and files wherever
possible. This avoids leaked files if a test fails.
Strip code from update_header that is related to CLI arguments.
We have a dedicated class for handling git related tasks. Therefore we
should use it here too.
Ensure that the defaults are set and parsed correctly.
Extract testing of get_exclude_list into an own test case and simplify
parse_args test case.
The update_header function just expect a year, license and company name
at the end.
It's more likely that the exclude file doesn't exist. Therefore it is
better to check is the file exists then reacting on the file not found
exception.
For easy iterations that create a list from a list it's better to use
list comprehension and also it should be faster.
List and Tuple are obsolete with PEP 585 and Python 3.9.
Don't pass the cleanup_regexes to the function and instead just add a
flag to cleanup the updated file instead.
Improved usage and print also the defaults.
--year is the fallback of --changed if the year of the last git
modification can't be calculated. Therefore it should be allowed to be
set in conjunction with --changed.
We need a regex that matches all kind of company names not only
Greenbone. This also generalizes the code and makes update-header
independent of Greenbone specific use cases.
Improve the performance for creating the regexp pattern by caching them.
With this change they will be created on demand once and afterwards they
are used from the cache.
@bjoernricks bjoernricks merged commit 18b2757 into main Feb 26, 2024
17 checks passed
@bjoernricks bjoernricks deleted the update-header branch February 26, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
make release To trigger GitHub release action.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants