66
77import httpx
88import requests
9- from pathspec import pathspec
109
1110from comfy_cli import ui
1211
@@ -90,15 +89,26 @@ def download_file(url: str, local_filepath: pathlib.Path, headers: Optional[dict
9089
9190
9291def zip_files (zip_filename ):
93- gitignore_path = ".gitignore"
94- if not os .path .exists (gitignore_path ):
95- print (f"No .gitignore file found in { os .getcwd ()} , proceeding without it." )
96- gitignore = ""
97- else :
98- with open (gitignore_path , "r" ) as file :
99- gitignore = file .read ()
92+ """
93+ Zip all files in the current directory that are tracked by git.
94+ """
95+ try :
96+ # Get list of git-tracked files using git ls-files
97+ import subprocess
10098
101- spec = pathspec .PathSpec .from_lines ("gitwildmatch" , gitignore .splitlines ())
99+ git_files = subprocess .check_output (["git" , "ls-files" ], text = True ).splitlines ()
100+ # Zip only git-tracked files
101+ with zipfile .ZipFile (zip_filename , "w" , zipfile .ZIP_DEFLATED ) as zipf :
102+ for file_path in git_files :
103+ if zip_filename in file_path :
104+ continue
105+ if os .path .exists (file_path ):
106+ zipf .write (file_path )
107+ else :
108+ print (f"File not found. Not including in zip: { file_path } " )
109+ return
110+ except (subprocess .SubprocessError , FileNotFoundError ):
111+ print ("Warning: Not in a git repository or git not installed. Zipping all files." )
102112
103113 with zipfile .ZipFile (zip_filename , "w" , zipfile .ZIP_DEFLATED ) as zipf :
104114 for root , dirs , files in os .walk ("." ):
@@ -110,8 +120,7 @@ def zip_files(zip_filename):
110120 if zip_filename in file_path :
111121 continue
112122 relative_path = os .path .relpath (file_path , start = "." )
113- if not spec .match_file (relative_path ):
114- zipf .write (file_path , relative_path )
123+ zipf .write (file_path , relative_path )
115124
116125
117126def upload_file_to_signed_url (signed_url : str , file_path : str ):
0 commit comments