Преглед изворни кода

only write .gitignore if needed (#3618)

benedikt-bartscher пре 10 месеци
родитељ
комит
09ff952d01
1 измењених фајлова са 7 додато и 1 уклоњено
  1. 7 1
      reflex/utils/prerequisites.py

+ 7 - 1
reflex/utils/prerequisites.py

@@ -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: