瀏覽代碼

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.
     """
     # 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: