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

IndexError while removing license file in files containing just the license header #25

Closed
M5oul opened this issue Feb 10, 2022 · 2 comments

Comments

@M5oul
Copy link

M5oul commented Feb 10, 2022

Hi, and thanks for this nice tool!

I found a bug, when trying to remove the header of a file which only contains the header (typically __init__.py), I get following error:

  File "site-packages/pre_commit_hooks/insert_license.py", line 206, in license_found
    if src_file_content[license_header_index + len(license_info.prefixed_license)].strip():
IndexError: list index out of range

if src_file_content[license_header_index + len(license_info.prefixed_license)].strip():

I added a -1 in the equation and it fixes the issue. I tried to go a bit further by fixing how license_header_index is computed, but I am afraid I don’t get everything, so I would prefer that you fix it the best way.

Thanks.

@Lucas-C
Copy link
Owner

Lucas-C commented Feb 10, 2022

Thank you for reporting the bug!

I'm going to get a look a this.

Lucas-C added a commit that referenced this issue Feb 10, 2022
@Lucas-C
Copy link
Owner

Lucas-C commented Feb 10, 2022

Fixed in c7dd3ca

@Lucas-C Lucas-C closed this as completed Feb 10, 2022
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

No branches or pull requests

2 participants