Skip to content

Commit

Permalink
Fixed license tool to keep line breaks on license update (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
intuibase authored Aug 22, 2024
1 parent d5a85f0 commit 1f4a9e7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/license/insert_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ def find_php_tag(lines):


def replace_header(content, php_file):
lines = content.splitlines()
lines = content.splitlines(True)
header_end_index = find_header_end(lines)
header_start_index = find_header_start(lines)

if header_start_index != -1:
content = "\n".join(lines[0:header_start_index])
content += "\n" + new_header
content = "".join(lines[0:header_start_index])
# if len(content) > 0:
# content += "\n"
content += new_header

if header_end_index != -1:
content += "\n".join(lines[header_end_index + 1:])
content += "".join(lines[header_end_index + 1:])
return content


Expand Down Expand Up @@ -99,7 +101,7 @@ def add_header_to_files(directory, extensions):
content = file.read()

php_file = filepath.endswith(".php")

if file_contains_license(filepath):
content = replace_header(content, php_file)
else:
Expand Down

0 comments on commit 1f4a9e7

Please sign in to comment.