only write .gitignore if needed (#3618)
This commit is contained in:
parent
e71acececc
commit
09ff952d01
@ -404,9 +404,15 @@ def initialize_gitignore(
|
|||||||
files_to_ignore: The files to add to the .gitignore file.
|
files_to_ignore: The files to add to the .gitignore file.
|
||||||
"""
|
"""
|
||||||
# Combine with the current ignored files.
|
# Combine with the current ignored files.
|
||||||
|
current_ignore: set[str] = set()
|
||||||
if os.path.exists(gitignore_file):
|
if os.path.exists(gitignore_file):
|
||||||
with open(gitignore_file, "r") as f:
|
with open(gitignore_file, "r") as f:
|
||||||
files_to_ignore |= set([line.strip() for line in f.readlines()])
|
current_ignore |= set([line.strip() for line in f.readlines()])
|
||||||
|
|
||||||
|
if files_to_ignore == current_ignore:
|
||||||
|
console.debug(f"{gitignore_file} already up to date.")
|
||||||
|
return
|
||||||
|
files_to_ignore |= current_ignore
|
||||||
|
|
||||||
# Write files to the .gitignore file.
|
# Write files to the .gitignore file.
|
||||||
with open(gitignore_file, "w", newline="\n") as f:
|
with open(gitignore_file, "w", newline="\n") as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user