@@ -49,7 +49,6 @@ def clone_sync_repository(self):
4949 """Clone the forked repository locally if it doesn't exist, or pull updates if it does."""
5050 logging .info ("Checking local repository..." )
5151 if not os .path .exists (self .local_clone_dir ):
52- # Directory doesn't exist, clone the repository
5352 logging .info ("Cloning forked repository..." )
5453 try :
5554 subprocess .run (
@@ -60,7 +59,6 @@ def clone_sync_repository(self):
6059 except subprocess .CalledProcessError as e :
6160 raise RuntimeError (f"Failed to clone repository: { e } " )
6261 else :
63- # Directory exists, pull the latest changes
6462 logging .info ("Local repository already exists. Pulling latest changes..." )
6563 try :
6664 os .chdir (self .local_clone_dir )
@@ -81,26 +79,20 @@ def create_branch(self, branch_name: str):
8179 def add_file (self , file_path : str , content ):
8280 """Add a new file to the local repository."""
8381 logging .info (f"Adding new file: { file_path } ..." )
84- os .chdir (self .local_clone_dir ) # Ensure we are in the Git repository
82+ os .chdir (self .local_clone_dir )
8583 full_path = Path (self .local_clone_dir ) / file_path
8684 full_path .parent .mkdir (parents = True , exist_ok = True )
87-
8885 # Ensure content is serializable
8986 if hasattr (content , "to_dict" ):
9087 content = content .to_dict ()
9188 if not isinstance (content , (dict , list , str , int , float , bool , type (None ))):
9289 raise TypeError (f"Cannot serialize content of type { type (content )} " )
93-
94- # Serialize to JSON
9590 try :
9691 json_content = json .dumps (content , indent = 2 , default = serialize )
9792 except TypeError as e :
9893 raise RuntimeError (f"JSON serialization failed: { e } " )
99-
10094 with open (full_path , "w" ) as f :
10195 f .write (json_content )
102-
103- # Git add the file
10496 try :
10597 subprocess .run (["git" , "add" , str (full_path )], check = True )
10698 except subprocess .CalledProcessError as e :
0 commit comments