fix
Browse filesFiles changed (2)
1316 unmodified lines13171318131913201321132213231324132513261327132813291330133113321333133497 unmodified lines143214331434142314351436143714381 unmodified line144014411442143114431444144511 unmodified lines145714581459146014491461146214631452146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861316 unmodified lines try: api = HfApi(token=token) # Check if we can access the space first try: space_info = api.space_info(repo_id=repo_id, token=token) print(f"[PR] Space info: private={space_info.private if hasattr(space_info, 'private') else 'unknown'}") # Check if space is private if hasattr(space_info, 'private') and space_info.private: return False, "❌ Cannot create PR on private space. The space must be public to accept PRs from others.", None except Exception as info_error: print(f"[PR] Could not fetch space info: {info_error}") # Continue anyway - maybe we can still create the PR # Default PR title and description if not pr_title: pr_title = "🎨 Redesign from AnyCoder"97 unmodified lines print(f"[PR] Prepared {len(operations)} file operations") # Create commit with PR # Create commit with PR (token already in HfApi instance) commit_info = api.create_commit( repo_id=repo_id, repo_type="space",1 unmodified line commit_message=pr_title, commit_description=pr_description, create_pr=True, # This creates a PR with the changes token=token ) # Extract PR URL11 unmodified lines return True, success_msg, pr_url except Exception as e: error_msg = str(e) print(f"[PR] Error creating pull request: {e}") print(f"[PR] Error creating pull request: {error_msg}") import traceback traceback.print_exc() return False, f"Failed to create pull request: {str(e)}", None # Provide helpful error message based on the error type if "403" in error_msg or "Forbidden" in error_msg or "Authorization" in error_msg: user_msg = ( "❌ Cannot create Pull Request: Permission denied.\n\n" "**Possible reasons:**\n" "- The space owner hasn't enabled Pull Requests\n" "- You don't have write access to this space\n" "- Spaces have stricter PR permissions than models/datasets\n\n" "**What you can do:**\n" "✅ Use the 'Redesign' button WITHOUT checking 'Create PR' - this will:\n" " 1. Duplicate the space to your account\n" " 2. Apply the redesign to your copy\n" " 3. You'll own the new space!\n\n" "Or contact the space owner to enable Pull Requests." ) else: user_msg = f"Failed to create pull request: {error_msg}" return False, user_msg, None except Exception as e: print(f"[PR] Top-level exception: {type(e).__name__}: {str(e)}")806 unmodified lines8078088098108108118128136 unmodified lines820821822823824825826827828829830831806 unmodified lines /> {/* PR Option */} <label className="flex items-center gap-2 mb-3 cursor-pointer"> <label className="flex items-center gap-2 mb-1 cursor-pointer"> <input type="checkbox" checked={createPR}6 unmodified lines </span> </label> {createPR && ( <p className="text-[10px] text-[#86868b] mb-2 ml-6"> ⚠️ Note: PR creation requires space owner to enable PRs. If disabled, uncheck this to duplicate the space instead. </p> )} {redesignError && ( <p className="text-xs text-red-400 mb-2">{redesignError}</p> )}backend_deploy.py+35-4
frontend/src/components/LandingPage.tsx+7-1