Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
yield f"โ ๏ธ Warning: LFS download failed"
|
| 470 |
skip_lfs = True
|
| 471 |
else:
|
| 472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|