Spaces:
Runtime error
Runtime error
File size: 1,243 Bytes
73b0044 7d2aa7c 73b0044 7d2aa7c 73b0044 cfafcbc 73b0044 cfafcbc 73b0044 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import subprocess
import os
import sys
def main():
# التأكد من وجود وسيطين: اسم الريبو ورقم الـ PR
if len(sys.argv) != 3:
print("الاستخدام الصحيح:")
print("python app.py <اسم_المستودع> <رقم_PR>")
print("مثال: python app.py osanseviero/InstantCoder 14")
return
repo = sys.argv[1]
pr_number = sys.argv[2]
dir_name = repo.split("/")[-1]
try:
# استنساخ المستودع
subprocess.run(["git", "clone", f"https://huggingface.co/spaces/{repo}"], check=True)
# الدخول إلى المجلد
os.chdir(dir_name)
# جلب الـ PR
subprocess.run(["git", "fetch", "origin", f"refs/pr/{pr_number}:pr/{pr_number}"], check=True)
# التبديل إلى الفرع
subprocess.run(["git", "checkout", f"pr/{pr_number}"], check=True)
print(f"تم بنجاح التبديل إلى PR #{pr_number} في المستودع {repo}")
except subprocess.CalledProcessError as e:
print(f"حدث خطأ أثناء تنفيذ أمر git: {e}")
except Exception as e:
print(f"خطأ عام: {e}")
if __name__ == "__main__":
main() |