18 lines
530 B
Python
18 lines
530 B
Python
# open gitignore file, remove comments, blank lines and duplicate entries
|
|
def clean_gitignore(file_path: str):
|
|
with open(file_path, "r") as file:
|
|
lines = file.readlines()
|
|
|
|
cleaned_lines = set()
|
|
for line in lines:
|
|
stripped_line = line.strip()
|
|
if stripped_line and not stripped_line.startswith("#"):
|
|
cleaned_lines.add(stripped_line)
|
|
|
|
with open(file_path, "w") as file:
|
|
for line in sorted(cleaned_lines):
|
|
file.write(f"{line}\n")
|
|
|
|
|
|
clean_gitignore(".gitignore")
|