continuum-task-server-bundle 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- continuum_task_server_bundle/__init__.py +1 -0
- continuum_task_server_bundle/daytona/__init__.py +4 -0
- continuum_task_server_bundle/daytona/common.py +534 -0
- continuum_task_server_bundle/daytona/create_sandbox.py +166 -0
- continuum_task_server_bundle/daytona/dispatch.py +125 -0
- continuum_task_server_bundle/daytona/execute_sandbox.py +243 -0
- continuum_task_server_bundle/daytona/filesystem.py +330 -0
- continuum_task_server_bundle/daytona/fs_edit.py +127 -0
- continuum_task_server_bundle/daytona/git_ops.py +585 -0
- continuum_task_server_bundle/daytona/github_app.py +207 -0
- continuum_task_server_bundle/daytona/manage_sandbox.py +104 -0
- continuum_task_server_bundle/daytona/plugin.py +18 -0
- continuum_task_server_bundle/daytona/s3_transfer.py +207 -0
- continuum_task_server_bundle/discord/__init__.py +4 -0
- continuum_task_server_bundle/discord/attachment_registry_db.py +127 -0
- continuum_task_server_bundle/discord/attachment_resolve.py +213 -0
- continuum_task_server_bundle/discord/await_cleanup.py +105 -0
- continuum_task_server_bundle/discord/discord_ready.py +39 -0
- continuum_task_server_bundle/discord/message_await_apply.py +143 -0
- continuum_task_server_bundle/discord/message_await_db.py +197 -0
- continuum_task_server_bundle/discord/message_await_inbound.py +54 -0
- continuum_task_server_bundle/discord/message_await_logic.py +133 -0
- continuum_task_server_bundle/discord/message_await_poller.py +122 -0
- continuum_task_server_bundle/discord/message_chunking.py +45 -0
- continuum_task_server_bundle/discord/methods.py +408 -0
- continuum_task_server_bundle/discord/plugin.py +105 -0
- continuum_task_server_bundle/discord/reaction_await_apply.py +238 -0
- continuum_task_server_bundle/discord/reaction_await_db.py +174 -0
- continuum_task_server_bundle/discord/reaction_await_inbound.py +47 -0
- continuum_task_server_bundle/discord/reaction_await_logic.py +118 -0
- continuum_task_server_bundle/discord/reaction_await_poller.py +131 -0
- continuum_task_server_bundle/discord/s3_attachment_config.py +25 -0
- continuum_task_server_bundle/discord/s3_message_attachments.py +139 -0
- continuum_task_server_bundle/discord/sql/001_message_awaits.sql +112 -0
- continuum_task_server_bundle/discord/sql/002_reaction_awaits.sql +61 -0
- continuum_task_server_bundle/github/__init__.py +4 -0
- continuum_task_server_bundle/github/awaits/__init__.py +1 -0
- continuum_task_server_bundle/github/awaits/apply.py +92 -0
- continuum_task_server_bundle/github/awaits/cleanup.py +94 -0
- continuum_task_server_bundle/github/awaits/db.py +220 -0
- continuum_task_server_bundle/github/awaits/evaluators.py +325 -0
- continuum_task_server_bundle/github/awaits/fetch.py +192 -0
- continuum_task_server_bundle/github/awaits/poller.py +82 -0
- continuum_task_server_bundle/github/awaits/register.py +37 -0
- continuum_task_server_bundle/github/ci_status.py +70 -0
- continuum_task_server_bundle/github/comment_normalize.py +76 -0
- continuum_task_server_bundle/github/errors.py +52 -0
- continuum_task_server_bundle/github/github_app.py +291 -0
- continuum_task_server_bundle/github/github_http.py +377 -0
- continuum_task_server_bundle/github/methods/__init__.py +90 -0
- continuum_task_server_bundle/github/methods/_common.py +183 -0
- continuum_task_server_bundle/github/methods/awaits.py +107 -0
- continuum_task_server_bundle/github/methods/ci.py +158 -0
- continuum_task_server_bundle/github/methods/comments.py +214 -0
- continuum_task_server_bundle/github/methods/credentials.py +59 -0
- continuum_task_server_bundle/github/methods/issues.py +131 -0
- continuum_task_server_bundle/github/methods/pulls.py +329 -0
- continuum_task_server_bundle/github/methods/repos.py +424 -0
- continuum_task_server_bundle/github/methods/search.py +109 -0
- continuum_task_server_bundle/github/plugin.py +91 -0
- continuum_task_server_bundle/github/sql/001_github_awaits.sql +65 -0
- continuum_task_server_bundle/github/webhook_server.py +126 -0
- continuum_task_server_bundle/jira/__init__.py +4 -0
- continuum_task_server_bundle/jira/await_poller.py +236 -0
- continuum_task_server_bundle/jira/await_store.py +271 -0
- continuum_task_server_bundle/jira/config.py +68 -0
- continuum_task_server_bundle/jira/jira_client.py +382 -0
- continuum_task_server_bundle/jira/methods.py +246 -0
- continuum_task_server_bundle/jira/plugin.py +86 -0
- continuum_task_server_bundle/jira/sql/001_jira_issue_comment_waits.sql +19 -0
- continuum_task_server_bundle/jira/webhook.py +70 -0
- continuum_task_server_bundle/openrouter/__init__.py +4 -0
- continuum_task_server_bundle/openrouter/chat_service.py +1037 -0
- continuum_task_server_bundle/openrouter/chat_store.py +849 -0
- continuum_task_server_bundle/openrouter/environment.py +29 -0
- continuum_task_server_bundle/openrouter/handler.py +59 -0
- continuum_task_server_bundle/openrouter/image_context.py +207 -0
- continuum_task_server_bundle/openrouter/openrouter_client.py +324 -0
- continuum_task_server_bundle/openrouter/plugin.py +37 -0
- continuum_task_server_bundle/openrouter/prompt_projection.py +417 -0
- continuum_task_server_bundle/openrouter/sql/chat.sql +50 -0
- continuum_task_server_bundle/openrouter/sql/migrate_prune_then_chunk_v1.sql +11 -0
- continuum_task_server_bundle/roblox/__init__.py +4 -0
- continuum_task_server_bundle/roblox/open_cloud.py +335 -0
- continuum_task_server_bundle/roblox/plugin.py +30 -0
- continuum_task_server_bundle/roblox/storage_s3.py +55 -0
- continuum_task_server_bundle-1.0.0.dist-info/METADATA +109 -0
- continuum_task_server_bundle-1.0.0.dist-info/RECORD +90 -0
- continuum_task_server_bundle-1.0.0.dist-info/WHEEL +5 -0
- continuum_task_server_bundle-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
"""Pull request methods."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from continuum_task_server_bundle.github.errors import GitHubRequestError, InputError
|
|
8
|
+
from continuum_task_server_bundle.github.methods._common import (
|
|
9
|
+
Call,
|
|
10
|
+
as_bool,
|
|
11
|
+
opt_int,
|
|
12
|
+
require_number,
|
|
13
|
+
require_repo,
|
|
14
|
+
require_str,
|
|
15
|
+
trim_pr,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
_REVIEW_EVENTS = {"APPROVE", "REQUEST_CHANGES", "COMMENT"}
|
|
19
|
+
_MERGE_METHODS = {"merge", "squash", "rebase"}
|
|
20
|
+
|
|
21
|
+
_READY_MUTATION = """
|
|
22
|
+
mutation ($id: ID!) {
|
|
23
|
+
markPullRequestReadyForReview(input: {pullRequestId: $id}) {
|
|
24
|
+
pullRequest { number isDraft url }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def create_pull_request(call: Call) -> dict[str, Any]:
|
|
31
|
+
owner, name = require_repo(call.data)
|
|
32
|
+
repo = f"{owner}/{name}"
|
|
33
|
+
head = require_str(call.data, "head")
|
|
34
|
+
title = require_str(call.data, "title")
|
|
35
|
+
base = call.data.get("base")
|
|
36
|
+
if not base:
|
|
37
|
+
repo_body = call.app.rest("GET", f"/repos/{owner}/{name}", repo=repo).data or {}
|
|
38
|
+
base = repo_body.get("default_branch")
|
|
39
|
+
if not base:
|
|
40
|
+
raise InputError("base is required and the repo has no default branch")
|
|
41
|
+
body: dict[str, Any] = {
|
|
42
|
+
"title": title,
|
|
43
|
+
"head": head,
|
|
44
|
+
"base": base,
|
|
45
|
+
"body": call.data.get("body") or "",
|
|
46
|
+
"draft": as_bool(call.data.get("draft"), default=False),
|
|
47
|
+
}
|
|
48
|
+
if call.data.get("maintainer_can_modify") is not None:
|
|
49
|
+
body["maintainer_can_modify"] = as_bool(call.data.get("maintainer_can_modify"), default=True)
|
|
50
|
+
try:
|
|
51
|
+
created = call.app.rest("POST", f"/repos/{owner}/{name}/pulls", repo=repo, json_body=body).data or {}
|
|
52
|
+
return {"success": True, "existing": False, "pull_request": trim_pr(created)}
|
|
53
|
+
except GitHubRequestError as exc:
|
|
54
|
+
if exc.status != 422:
|
|
55
|
+
raise
|
|
56
|
+
head_query = head if ":" in head else f"{owner}:{head}"
|
|
57
|
+
listed = call.app.rest(
|
|
58
|
+
"GET",
|
|
59
|
+
f"/repos/{owner}/{name}/pulls",
|
|
60
|
+
repo=repo,
|
|
61
|
+
params={"head": head_query, "base": base, "state": "open"},
|
|
62
|
+
).data or []
|
|
63
|
+
if isinstance(listed, list) and listed:
|
|
64
|
+
return {"success": True, "existing": True, "pull_request": trim_pr(listed[0])}
|
|
65
|
+
raise
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def get_pull_request(call: Call) -> dict[str, Any]:
|
|
69
|
+
owner, name = require_repo(call.data)
|
|
70
|
+
number = require_number(call.data, "number", "pr_number")
|
|
71
|
+
repo = f"{owner}/{name}"
|
|
72
|
+
pull = call.app.rest("GET", f"/repos/{owner}/{name}/pulls/{number}", repo=repo).data or {}
|
|
73
|
+
if pull.get("mergeable") is None:
|
|
74
|
+
pull = call.app.rest("GET", f"/repos/{owner}/{name}/pulls/{number}", repo=repo).data or pull
|
|
75
|
+
decision = _review_decision(call, owner, name, number)
|
|
76
|
+
return {"success": True, "pull_request": trim_pr(pull, review_decision=decision)}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def list_pull_requests(call: Call) -> dict[str, Any]:
|
|
80
|
+
owner, name = require_repo(call.data)
|
|
81
|
+
repo = f"{owner}/{name}"
|
|
82
|
+
per_page = min(100, max(1, opt_int(call.data, "per_page", "limit", default=30)))
|
|
83
|
+
pulls = call.app.rest(
|
|
84
|
+
"GET",
|
|
85
|
+
f"/repos/{owner}/{name}/pulls",
|
|
86
|
+
repo=repo,
|
|
87
|
+
params={
|
|
88
|
+
"state": call.data.get("state") or "open",
|
|
89
|
+
"head": call.data.get("head"),
|
|
90
|
+
"base": call.data.get("base"),
|
|
91
|
+
"per_page": per_page,
|
|
92
|
+
"sort": call.data.get("sort"),
|
|
93
|
+
"direction": call.data.get("direction"),
|
|
94
|
+
},
|
|
95
|
+
).data or []
|
|
96
|
+
if isinstance(pulls, dict):
|
|
97
|
+
pulls = []
|
|
98
|
+
return {"success": True, "pull_requests": [trim_pr(pull) for pull in pulls]}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def list_pr_files(call: Call) -> dict[str, Any]:
|
|
102
|
+
owner, name = require_repo(call.data)
|
|
103
|
+
number = require_number(call.data, "number", "pr_number")
|
|
104
|
+
repo = f"{owner}/{name}"
|
|
105
|
+
per_page = min(100, max(1, opt_int(call.data, "per_page", "limit", default=100)))
|
|
106
|
+
files = call.app.rest(
|
|
107
|
+
"GET",
|
|
108
|
+
f"/repos/{owner}/{name}/pulls/{number}/files",
|
|
109
|
+
repo=repo,
|
|
110
|
+
params={"per_page": per_page},
|
|
111
|
+
paginate=True,
|
|
112
|
+
max_pages=max(1, (300 + per_page - 1) // per_page),
|
|
113
|
+
).data or []
|
|
114
|
+
trimmed = []
|
|
115
|
+
for item in files[:300]:
|
|
116
|
+
patch = item.get("patch") or ""
|
|
117
|
+
trimmed.append(
|
|
118
|
+
{
|
|
119
|
+
"filename": item.get("filename"),
|
|
120
|
+
"status": item.get("status"),
|
|
121
|
+
"additions": item.get("additions"),
|
|
122
|
+
"deletions": item.get("deletions"),
|
|
123
|
+
"changes": item.get("changes"),
|
|
124
|
+
"patch": patch[:4000],
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
return {"success": True, "files": trimmed}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def get_pr_diff(call: Call) -> dict[str, Any]:
|
|
131
|
+
owner, name = require_repo(call.data)
|
|
132
|
+
number = require_number(call.data, "number", "pr_number")
|
|
133
|
+
repo = f"{owner}/{name}"
|
|
134
|
+
max_chars = min(1_000_000, max(1, opt_int(call.data, "max_chars", default=200_000)))
|
|
135
|
+
response = call.app.rest(
|
|
136
|
+
"GET",
|
|
137
|
+
f"/repos/{owner}/{name}/pulls/{number}",
|
|
138
|
+
repo=repo,
|
|
139
|
+
accept="application/vnd.github.diff",
|
|
140
|
+
)
|
|
141
|
+
diff = response.data if isinstance(response.data, str) else ""
|
|
142
|
+
truncated = len(diff) > max_chars
|
|
143
|
+
return {"success": True, "diff": diff[:max_chars], "truncated": truncated}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def update_pull_request(call: Call) -> dict[str, Any]:
|
|
147
|
+
owner, name = require_repo(call.data)
|
|
148
|
+
number = require_number(call.data, "number", "pr_number")
|
|
149
|
+
repo = f"{owner}/{name}"
|
|
150
|
+
body: dict[str, Any] = {}
|
|
151
|
+
for key in ("title", "body", "base", "state"):
|
|
152
|
+
if call.data.get(key) is not None:
|
|
153
|
+
body[key] = call.data[key]
|
|
154
|
+
if not body:
|
|
155
|
+
raise InputError("one of title, body, base, or state is required")
|
|
156
|
+
if "state" in body and body["state"] not in ("open", "closed"):
|
|
157
|
+
raise InputError("state must be open or closed")
|
|
158
|
+
updated = call.app.rest(
|
|
159
|
+
"PATCH",
|
|
160
|
+
f"/repos/{owner}/{name}/pulls/{number}",
|
|
161
|
+
repo=repo,
|
|
162
|
+
json_body=body,
|
|
163
|
+
).data or {}
|
|
164
|
+
return {"success": True, "pull_request": trim_pr(updated)}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def mark_ready_for_review(call: Call) -> dict[str, Any]:
|
|
168
|
+
owner, name = require_repo(call.data)
|
|
169
|
+
number = require_number(call.data, "number", "pr_number")
|
|
170
|
+
repo = f"{owner}/{name}"
|
|
171
|
+
pull = call.app.rest("GET", f"/repos/{owner}/{name}/pulls/{number}", repo=repo).data or {}
|
|
172
|
+
node_id = pull.get("node_id")
|
|
173
|
+
if not node_id:
|
|
174
|
+
raise InputError("pull request has no node_id")
|
|
175
|
+
if pull.get("draft") is False:
|
|
176
|
+
return {"success": True, "pull_request": trim_pr(pull), "already_ready": True}
|
|
177
|
+
data = call.app.graphql(_READY_MUTATION, {"id": node_id}, repo=repo)
|
|
178
|
+
pr = ((data.get("markPullRequestReadyForReview") or {}).get("pullRequest")) or {}
|
|
179
|
+
return {
|
|
180
|
+
"success": True,
|
|
181
|
+
"number": pr.get("number") or number,
|
|
182
|
+
"draft": pr.get("isDraft"),
|
|
183
|
+
"html_url": pr.get("url") or pull.get("html_url"),
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def request_reviewers(call: Call) -> dict[str, Any]:
|
|
188
|
+
owner, name = require_repo(call.data)
|
|
189
|
+
number = require_number(call.data, "number", "pr_number")
|
|
190
|
+
reviewers = call.data.get("reviewers") or []
|
|
191
|
+
teams = call.data.get("team_reviewers") or []
|
|
192
|
+
if not reviewers and not teams:
|
|
193
|
+
raise InputError("reviewers or team_reviewers is required")
|
|
194
|
+
repo = f"{owner}/{name}"
|
|
195
|
+
result = call.app.rest(
|
|
196
|
+
"POST",
|
|
197
|
+
f"/repos/{owner}/{name}/pulls/{number}/requested_reviewers",
|
|
198
|
+
repo=repo,
|
|
199
|
+
json_body={"reviewers": reviewers, "team_reviewers": teams},
|
|
200
|
+
).data or {}
|
|
201
|
+
requested = [user.get("login") for user in (result.get("requested_reviewers") or []) if isinstance(user, dict)]
|
|
202
|
+
return {"success": True, "requested_reviewers": requested}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def create_review(call: Call) -> dict[str, Any]:
|
|
206
|
+
owner, name = require_repo(call.data)
|
|
207
|
+
number = require_number(call.data, "number", "pr_number")
|
|
208
|
+
event = str(call.data.get("event") or "COMMENT").upper()
|
|
209
|
+
if event not in _REVIEW_EVENTS:
|
|
210
|
+
raise InputError("event must be APPROVE, REQUEST_CHANGES, or COMMENT")
|
|
211
|
+
repo = f"{owner}/{name}"
|
|
212
|
+
body: dict[str, Any] = {"event": event}
|
|
213
|
+
if call.data.get("body") is not None:
|
|
214
|
+
body["body"] = call.data["body"]
|
|
215
|
+
if call.data.get("commit_id") or call.data.get("sha"):
|
|
216
|
+
body["commit_id"] = call.data.get("commit_id") or call.data.get("sha")
|
|
217
|
+
comments = call.data.get("comments")
|
|
218
|
+
if comments is not None:
|
|
219
|
+
if not isinstance(comments, list):
|
|
220
|
+
raise InputError("comments must be a list")
|
|
221
|
+
body["comments"] = comments
|
|
222
|
+
review = call.app.rest(
|
|
223
|
+
"POST",
|
|
224
|
+
f"/repos/{owner}/{name}/pulls/{number}/reviews",
|
|
225
|
+
repo=repo,
|
|
226
|
+
json_body=body,
|
|
227
|
+
).data or {}
|
|
228
|
+
user = review.get("user") or {}
|
|
229
|
+
return {
|
|
230
|
+
"success": True,
|
|
231
|
+
"review_id": review.get("id"),
|
|
232
|
+
"state": review.get("state"),
|
|
233
|
+
"user_login": user.get("login") if isinstance(user, dict) else None,
|
|
234
|
+
"html_url": review.get("html_url"),
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def update_branch(call: Call) -> dict[str, Any]:
|
|
239
|
+
owner, name = require_repo(call.data)
|
|
240
|
+
number = require_number(call.data, "number", "pr_number")
|
|
241
|
+
repo = f"{owner}/{name}"
|
|
242
|
+
body: dict[str, Any] = {}
|
|
243
|
+
if call.data.get("expected_head_sha") or call.data.get("sha"):
|
|
244
|
+
body["expected_head_sha"] = call.data.get("expected_head_sha") or call.data.get("sha")
|
|
245
|
+
response = call.app.rest(
|
|
246
|
+
"PUT",
|
|
247
|
+
f"/repos/{owner}/{name}/pulls/{number}/update-branch",
|
|
248
|
+
repo=repo,
|
|
249
|
+
json_body=body or None,
|
|
250
|
+
)
|
|
251
|
+
message = None
|
|
252
|
+
if isinstance(response.data, dict):
|
|
253
|
+
message = response.data.get("message")
|
|
254
|
+
return {"success": True, "status": response.status, "message": message}
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def merge_pull_request(call: Call) -> dict[str, Any]:
|
|
258
|
+
owner, name = require_repo(call.data)
|
|
259
|
+
number = require_number(call.data, "number", "pr_number")
|
|
260
|
+
method = str(call.data.get("merge_method") or "merge")
|
|
261
|
+
if method not in _MERGE_METHODS:
|
|
262
|
+
raise InputError("merge_method must be merge, squash, or rebase")
|
|
263
|
+
repo = f"{owner}/{name}"
|
|
264
|
+
body: dict[str, Any] = {"merge_method": method}
|
|
265
|
+
sha = call.data.get("sha")
|
|
266
|
+
if sha:
|
|
267
|
+
body["sha"] = sha
|
|
268
|
+
if call.data.get("commit_title"):
|
|
269
|
+
body["commit_title"] = call.data["commit_title"]
|
|
270
|
+
if call.data.get("commit_message"):
|
|
271
|
+
body["commit_message"] = call.data["commit_message"]
|
|
272
|
+
result = call.app.rest(
|
|
273
|
+
"PUT",
|
|
274
|
+
f"/repos/{owner}/{name}/pulls/{number}/merge",
|
|
275
|
+
repo=repo,
|
|
276
|
+
json_body=body,
|
|
277
|
+
).data or {}
|
|
278
|
+
return {
|
|
279
|
+
"success": True,
|
|
280
|
+
"merged": bool(result.get("merged", True)),
|
|
281
|
+
"sha": result.get("sha"),
|
|
282
|
+
"message": result.get("message"),
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def close_pull_request(call: Call) -> dict[str, Any]:
|
|
287
|
+
owner, name = require_repo(call.data)
|
|
288
|
+
number = require_number(call.data, "number", "pr_number")
|
|
289
|
+
repo = f"{owner}/{name}"
|
|
290
|
+
updated = call.app.rest(
|
|
291
|
+
"PATCH",
|
|
292
|
+
f"/repos/{owner}/{name}/pulls/{number}",
|
|
293
|
+
repo=repo,
|
|
294
|
+
json_body={"state": "closed"},
|
|
295
|
+
).data or {}
|
|
296
|
+
return {"success": True, "pull_request": trim_pr(updated)}
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def _review_decision(call: Call, owner: str, name: str, number: int) -> str | None:
|
|
300
|
+
repo = f"{owner}/{name}"
|
|
301
|
+
reviews = call.app.rest(
|
|
302
|
+
"GET",
|
|
303
|
+
f"/repos/{owner}/{name}/pulls/{number}/reviews",
|
|
304
|
+
repo=repo,
|
|
305
|
+
params={"per_page": 100},
|
|
306
|
+
paginate=True,
|
|
307
|
+
max_pages=5,
|
|
308
|
+
).data or []
|
|
309
|
+
if isinstance(reviews, dict):
|
|
310
|
+
return None
|
|
311
|
+
latest: dict[str, dict[str, Any]] = {}
|
|
312
|
+
for review in reviews:
|
|
313
|
+
user = review.get("user") or {}
|
|
314
|
+
login = user.get("login") if isinstance(user, dict) else None
|
|
315
|
+
state = review.get("state")
|
|
316
|
+
if not login or state not in ("APPROVED", "CHANGES_REQUESTED", "COMMENTED"):
|
|
317
|
+
continue
|
|
318
|
+
previous = latest.get(login)
|
|
319
|
+
submitted = review.get("submitted_at") or ""
|
|
320
|
+
if previous is None or str(submitted) >= str(previous.get("submitted_at") or ""):
|
|
321
|
+
latest[login] = review
|
|
322
|
+
states = {review.get("state") for review in latest.values()}
|
|
323
|
+
if "CHANGES_REQUESTED" in states:
|
|
324
|
+
return "CHANGES_REQUESTED"
|
|
325
|
+
if "APPROVED" in states:
|
|
326
|
+
return "APPROVED"
|
|
327
|
+
if states:
|
|
328
|
+
return "COMMENTED"
|
|
329
|
+
return None
|