You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running update_license_header.py, some files that already have a license header are not being updated or removed as expected. The script is supposed to replace existing license headers with the new one or remove them if the --delete flag is used. However, in certain cases, the header remains unchanged.
Steps to Reproduce:
Run the script on a directory containing files with an existing license header:
When running update_license_header.py, some files that already have a license header are not being updated or removed as expected. The script is supposed to replace existing license headers with the new one or remove them if the --delete flag is used. However, in certain cases, the header remains unchanged.
Steps to Reproduce:
Run the script on a directory containing files with an existing license header:
python update_license_header.py -d ./test_directory
Check the modified files. Some files retain the old license header instead of getting updated.
Run the script with the --delete flag:
python update_license_header.py -d ./test_directory --delete
Observe that in some files, the license header is not removed.
Expected Behavior:
The script should replace any existing license header with the new one.
When using --delete, the license header should be completely removed.
Actual Behavior:
Some files do not have their license headers updated or removed as expected.
Possible Cause:
The regex pattern used to match existing headers may not correctly capture all variations of the license header format.
re.sub() might not be correctly modifying the file content in all cases.
Suggested Fix:
Improve the regex pattern to handle different variations of the license header more effectively:
pattern = re.compile(
r'(["']{3}|/[])\n(*)~.?~(*)\n(["']{3}|[]/)(\r\n|\r|\n)',
re.DOTALL | re.MULTILINE
)
Ensure re.sub() correctly modifies the content by checking the result before writing it back to the file.
Environment:
OS: [e.g., Ubuntu 22.04, Windows 10]
Python version: [e.g., 3.8, 3.10]
Script version: [commit hash or version number if applicable]
Additional Information:Any additional details, logs, or related issues can be added here.
The text was updated successfully, but these errors were encountered: