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

Method update_pr

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

Update a PR's title, body, state, or base branch.

(
        self,
        pr_number: int,
        title: str | None = None,
        body: str | None = None,
        state: str | None = None,
        base: str | None = None,
    )

Source from the content-addressed store, hash-verified

626 return {"error": str(e)}
627
628 async def update_pr(
629 self,
630 pr_number: int,
631 title: str | None = None,
632 body: str | None = None,
633 state: str | None = None,
634 base: str | None = None,
635 ) -> dict:
636 """Update a PR's title, body, state, or base branch."""
637 if not self._has_auth():
638 return {"error": "GitHub token not configured"}
639
640 if not any([title, body, state, base]):
641 return {"error": "At least one field required"}
642
643 url = f"https://api.github.com/repos/{self.repo}/pulls/{pr_number}"
644 payload = {}
645 if title:
646 payload["title"] = title
647 if body:
648 payload["body"] = body
649 if state and state in ["open", "closed"]:
650 payload["state"] = state
651 if base:
652 payload["base"] = base
653
654 try:
655 session = await self.get_session()
656 async with session.patch(url, json=payload, headers=await self._get_headers()) as response:
657 if response.status == 200:
658 return {
659 "success": True,
660 "pr_number": pr_number,
661 "updated": list(payload.keys()),
662 "pr_url": f"https://github.com/{self.repo}/pull/{pr_number}",
663 }
664 elif response.status == 404:
665 return {"error": f"PR #{pr_number} not found", "not_found": True}
666 else:
667 return {"error": f"GitHub API error: {response.status}"}
668 except Exception as e:
669 logger.error(f"Error updating PR: {e}")
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."""

Callers 1

tool_github_prFunction · 0.80

Calls 5

_has_authMethod · 0.95
get_sessionMethod · 0.95
_get_headersMethod · 0.95
errorMethod · 0.80
listFunction · 0.50

Tested by

no test coverage detected