Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
vrigal committed Dec 9, 2024
1 parent b596b99 commit 08e596f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bot/code_review_bot/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,29 @@ def list_diff_issues(self, diff_id):

def list_diff_issues_v2(self, diff_id, mode):
"""
List issues for a given dif
List issues for a given diff, applying specific filters.
Returns:
* The ID of the previous diff if it exists (always null for `known` mode).
* A list of issues (dict serializing ID and hash) corresponding to the filter.
"""
assert mode in ("known", "unresolved", "closed")
try:
return list(self.paginate(f"/v2/diff/{diff_id}/issues/{mode}"))
data = self.get(f"/v2/diff/{diff_id}/issues/{mode}")
except HTTPError as e:
if e.response.status_code != 404:
logger.warning(
f"Cound not list {mode} issues from the bot: {e}. Skipping"
f"Could not list {mode} issues from the bot: {e}. Skipping"
)
else:
logger.info(f"Diff not found in code review backend: {diff_id}")
return []
return None, []
return data["previous_diff_id"], data["issues"]

def get(self, url):
auth = (self.username, self.password)
resp = requests.get(url, auth=auth, headers=GetAppUserAgent())
resp.raise_for_status()
return resp.json()

def paginate(self, url_path):
"""
Expand Down

0 comments on commit 08e596f

Please sign in to comment.