From 09ff952d01559d492a28be7d7103a25f52e83d38 Mon Sep 17 00:00:00 2001 From: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com> Date: Tue, 9 Jul 2024 04:19:19 +0200 Subject: [PATCH] only write .gitignore if needed (#3618) --- reflex/utils/prerequisites.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 3e0e11517..581f9c79d 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -404,9 +404,15 @@ def initialize_gitignore( files_to_ignore: The files to add to the .gitignore file. """ # Combine with the current ignored files. + current_ignore: set[str] = set() if os.path.exists(gitignore_file): 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. with open(gitignore_file, "w", newline="\n") as f: