fix
Browse filesFiles changed (2)
1316 unmodified lines13171318131913201321132297 unmodified lines14201421142214231424142514261 unmodified line142814291430143114321433143411 unmodified lines14461447144814491450145114521453145414551316 unmodified linestry:api = HfApi(token=token)# Default PR title and descriptionif not pr_title:pr_title = "🎨 Redesign from AnyCoder"97 unmodified linesprint(f"[PR] Prepared {len(operations)} file operations")# Create commit with PRcommit_info = api.create_commit(repo_id=repo_id,repo_type="space",1 unmodified linecommit_message=pr_title,commit_description=pr_description,create_pr=True, # This creates a PR with the changestoken=token)# Extract PR URL11 unmodified linesreturn True, success_msg, pr_urlexcept Exception as e:print(f"[PR] Error creating pull request: {e}")import tracebacktraceback.print_exc()return False, f"Failed to create pull request: {str(e)}", Noneexcept Exception as e:print(f"[PR] Top-level exception: {type(e).__name__}: {str(e)}")1316 unmodified lines13171318131913201321132213231324132513261327132813291330133113321333133497 unmodified lines14321433143414351436143714381 unmodified line14401441144214431444144511 unmodified lines1457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861316 unmodified linestry:api = HfApi(token=token)# Check if we can access the space firsttry: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 privateif 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.", Noneexcept 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 descriptionif not pr_title:pr_title = "🎨 Redesign from AnyCoder"97 unmodified linesprint(f"[PR] Prepared {len(operations)} file operations")# Create commit with PR (token already in HfApi instance)commit_info = api.create_commit(repo_id=repo_id,repo_type="space",1 unmodified linecommit_message=pr_title,commit_description=pr_description,create_pr=True, # This creates a PR with the changes)# Extract PR URL11 unmodified linesreturn True, success_msg, pr_urlexcept Exception as e:error_msg = str(e)print(f"[PR] Error creating pull request: {error_msg}")import tracebacktraceback.print_exc()# Provide helpful error message based on the error typeif "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, Noneexcept Exception as e:print(f"[PR] Top-level exception: {type(e).__name__}: {str(e)}")
806 unmodified lines8078088098108118128136 unmodified lines820821822823824825806 unmodified lines/>{/* PR Option */}<label className="flex items-center gap-2 mb-3 cursor-pointer"><inputtype="checkbox"checked={createPR}6 unmodified lines</span></label>{redesignError && (<p className="text-xs text-red-400 mb-2">{redesignError}</p>)}806 unmodified lines8078088098108118128136 unmodified lines820821822823824825826827828829830831806 unmodified lines/>{/* PR Option */}<label className="flex items-center gap-2 mb-1 cursor-pointer"><inputtype="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