MCPcopy Create free account
hub / github.com/pollinations/pollinations / create_pr

Method create_pr

apps/polly/src/services/github_pr.py:672–704  ·  view source on GitHub ↗

Create a new pull request.

(self, title: str, body: str, head: str, base: str = "main", draft: bool = False)

Source from the content-addressed store, hash-verified

670 return {"error": str(e)}
671
672 async def create_pr(self, title: str, body: str, head: str, base: str = "main", draft: bool = False) -> dict:
673 """Create a new pull request."""
674 if not self._has_auth():
675 return {"error": "GitHub token not configured"}
676
677 url = f"https://api.github.com/repos/{self.repo}/pulls"
678 payload = {
679 "title": title,
680 "body": body,
681 "head": head,
682 "base": base,
683 "draft": draft,
684 }
685
686 try:
687 session = await self.get_session()
688 async with session.post(url, json=payload, headers=await self._get_headers()) as response:
689 if response.status == 201:
690 data = await response.json()
691 return {
692 "success": True,
693 "pr_number": data["number"],
694 "pr_url": data["html_url"],
695 "state": "draft" if draft else "open",
696 }
697 elif response.status == 422:
698 error_data = await response.json()
699 return {"error": f"Cannot create PR: {error_data.get('message', 'validation failed')}"}
700 else:
701 return {"error": f"GitHub API error: {response.status}"}
702 except Exception as e:
703 logger.error(f"Error creating PR: {e}")
704 return {"error": str(e)}
705
706 async def convert_to_draft(self, pr_number: int) -> dict:
707 """Convert a PR to draft using GraphQL mutation."""

Callers 1

tool_github_prFunction · 0.80

Calls 6

_has_authMethod · 0.95
get_sessionMethod · 0.95
_get_headersMethod · 0.95
jsonMethod · 0.80
errorMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected