@@ -301,12 +301,28 @@ def load_repo_to_tmp_dir(self, sha: str | None = None) -> tuple[str, str]:
301
301
shutil .move (
302
302
s , d
303
303
) # move all directories from the root folder to the output directory
304
+ elif os .path .islink (s ):
305
+ link_target = os .readlink (s )
306
+ abs_target = os .path .normpath (os .path .join (os .path .dirname (s ), link_target ))
307
+ if abs_target .startswith (root_folder_path ):
308
+ rel_target = os .path .relpath (abs_target , os .path .dirname (s ))
309
+ target_in_dest = os .path .join (os .path .dirname (d ), rel_target )
310
+ try :
311
+ if os .path .exists (abs_target ) and not os .path .exists (target_in_dest ):
312
+ target_dir = os .path .dirname (target_in_dest )
313
+ os .makedirs (target_dir , exist_ok = True )
314
+ shutil .copy2 (abs_target , target_in_dest )
315
+ os .symlink (rel_target , d )
316
+ except OSError :
317
+ if os .path .exists (abs_target ):
318
+ shutil .copy2 (abs_target , d )
319
+ else :
320
+ if os .path .exists (abs_target ):
321
+ shutil .copy2 (abs_target , d )
304
322
else :
305
- # Skipping symlinks to prevent FileNotFoundError.
306
- if not os .path .islink (s ):
307
- shutil .copy2 (
308
- s , d
309
- ) # copy all files from the root folder to the output directory
323
+ shutil .copy2 (
324
+ s , d
325
+ ) # copy all files from the root folder to the output directory
310
326
311
327
shutil .rmtree (root_folder_path ) # remove the root folder
312
328
0 commit comments