openfree commited on
Commit
5db7d32
ยท
verified ยท
1 Parent(s): d3302fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -8
app.py CHANGED
@@ -452,24 +452,70 @@ def clone(repo_git, repo_hf, sdk_type, skip_lfs, enable_smart_generation):
452
  yield f"โŒ Authentication failed: {str(e)}"
453
  return
454
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
455
  yield f"๐Ÿ“ฅ Cloning repository from {repo_git}..."
456
 
457
  env = os.environ.copy()
458
  env['GIT_LFS_SKIP_SMUDGE'] = '1'
459
- clone_cmd = ['git', 'clone', '--recurse-submodules', repo_git, folder]
460
- subprocess.run(clone_cmd, check=True, env=env)
461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
  if not skip_lfs:
463
  yield "๐Ÿ“ฆ Attempting to download LFS files..."
464
  try:
465
- subprocess.run(['git', 'lfs', 'install'], cwd=folder, check=True)
466
- lfs_result = subprocess.run(['git', 'lfs', 'pull'], cwd=folder, capture_output=True, text=True)
467
-
468
- if lfs_result.returncode != 0:
469
- yield f"โš ๏ธ Warning: LFS download failed"
470
  skip_lfs = True
471
  else:
472
- yield "โœ… LFS files downloaded successfully"
 
 
 
 
 
 
 
473
  except Exception as e:
474
  yield f"โš ๏ธ LFS error: {str(e)}"
475
  skip_lfs = True
 
452
  yield f"โŒ Authentication failed: {str(e)}"
453
  return
454
 
455
+ # URL ์ •๊ทœํ™” ๋ฐ ๊ฒ€์ฆ
456
+ repo_git = repo_git.strip()
457
+
458
+ # .git ํ™•์žฅ์ž ์ถ”๊ฐ€ (ํ•„์š”ํ•œ ๊ฒฝ์šฐ)
459
+ if not repo_git.endswith('.git'):
460
+ repo_git_with_git = repo_git + '.git'
461
+ else:
462
+ repo_git_with_git = repo_git
463
+
464
+ # HTTPS URL๋กœ ๋ณ€ํ™˜
465
+ if repo_git.startswith('git@github.com:'):
466
+ repo_git = repo_git.replace('git@github.com:', 'https://github.com/')
467
+ elif not repo_git.startswith('http'):
468
+ yield "โŒ Invalid repository URL. Please use HTTPS URL (e.g., https://github.com/username/repo)"
469
+ return
470
+
471
  yield f"๐Ÿ“ฅ Cloning repository from {repo_git}..."
472
 
473
  env = os.environ.copy()
474
  env['GIT_LFS_SKIP_SMUDGE'] = '1'
 
 
475
 
476
+ # ๋จผ์ € .git ์—†์ด ์‹œ๋„
477
+ clone_cmd = ['git', 'clone', '--depth', '1', repo_git, folder]
478
+ result = subprocess.run(clone_cmd, env=env, capture_output=True, text=True)
479
+
480
+ # ์‹คํŒจํ•˜๋ฉด .git ์ถ”๊ฐ€ํ•˜์—ฌ ์žฌ์‹œ๋„
481
+ if result.returncode != 0:
482
+ if ".git" not in repo_git:
483
+ yield " Retrying with .git extension..."
484
+ clone_cmd = ['git', 'clone', '--depth', '1', repo_git_with_git, folder]
485
+ result = subprocess.run(clone_cmd, env=env, capture_output=True, text=True)
486
+
487
+ if result.returncode != 0:
488
+ error_msg = result.stderr
489
+ if "Repository not found" in error_msg or "fatal: repository" in error_msg:
490
+ yield f"โŒ Repository not found. Please check:"
491
+ yield f" 1. The repository URL is correct"
492
+ yield f" 2. The repository is public"
493
+ yield f" 3. The repository exists"
494
+ yield f" URL tried: {repo_git}"
495
+ else:
496
+ yield f"โŒ Git clone failed: {error_msg[:500]}"
497
+ return
498
+
499
+ yield "โœ… Repository cloned successfully"
500
+
501
+ # Git ํด๋ก  ์žฌ์‹œ๋„ ๋กœ์ง ๊ฐœ์„ 
502
  if not skip_lfs:
503
  yield "๐Ÿ“ฆ Attempting to download LFS files..."
504
  try:
505
+ # Git LFS ์„ค์น˜ ํ™•์ธ
506
+ lfs_check = subprocess.run(['git', 'lfs', 'version'], capture_output=True, text=True)
507
+ if lfs_check.returncode != 0:
508
+ yield "โš ๏ธ Git LFS not installed. Skipping LFS files..."
 
509
  skip_lfs = True
510
  else:
511
+ subprocess.run(['git', 'lfs', 'install'], cwd=folder, check=True)
512
+ lfs_result = subprocess.run(['git', 'lfs', 'pull'], cwd=folder, capture_output=True, text=True)
513
+
514
+ if lfs_result.returncode != 0:
515
+ yield f"โš ๏ธ Warning: LFS download failed - {lfs_result.stderr[:200]}"
516
+ skip_lfs = True
517
+ else:
518
+ yield "โœ… LFS files downloaded successfully"
519
  except Exception as e:
520
  yield f"โš ๏ธ LFS error: {str(e)}"
521
  skip_lfs = True