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

Class GitHubPRManager

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

GitHub Pull Request operations using GraphQL + REST APIs.

Source from the content-addressed store, hash-verified

81
82
83class GitHubPRManager:
84 """GitHub Pull Request operations using GraphQL + REST APIs."""
85
86 def __init__(self):
87 self._session: aiohttp.ClientSession | None = None
88
89 @property
90 def repo(self) -> str:
91 return config.github_repo
92
93 @property
94 def owner(self) -> str:
95 return self.repo.split("/")[0]
96
97 @property
98 def repo_name(self) -> str:
99 return self.repo.split("/")[1]
100
101 async def get_session(self) -> aiohttp.ClientSession:
102 if self._session is None or self._session.closed:
103 self._session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60, connect=10))
104 return self._session
105
106 async def close(self):
107 if self._session and not self._session.closed:
108 await self._session.close()
109 self._session = None
110
111 async def _get_token(self) -> str | None:
112 if github_auth.github_app_auth:
113 token = await github_auth.github_app_auth.get_token()
114 if token:
115 return token
116 return config.github_token if config.github_token else None
117
118 async def _get_headers(self) -> dict | None:
119 token = await self._get_token()
120 if not token:
121 return None
122 return {
123 "Authorization": f"Bearer {token}",
124 "Accept": "application/vnd.github.v3+json",
125 "X-GitHub-Api-Version": "2022-11-28",
126 }
127
128 def _has_auth(self) -> bool:
129 return github_auth.github_app_auth is not None or bool(config.github_token)
130
131 # ============================================================
132 # PR READ OPERATIONS (GraphQL)
133 # ============================================================
134
135 async def get_pr(self, pr_number: int) -> dict:
136 """Get full details of a pull request using GraphQL."""
137 if not self._has_auth():
138 return {"error": "GitHub token not configured"}
139
140 query = """

Callers 1

github_pr.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected