Compare commits
1 Commits
0b40e8dec9
...
3de15d20da
Author | SHA1 | Date | |
---|---|---|---|
3de15d20da |
|
@ -219,109 +219,3 @@ class GiteaClient:
|
||||||
response = self.session.get(url)
|
response = self.session.get(url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def get_pull_request_reviews(
|
|
||||||
self,
|
|
||||||
owner: str,
|
|
||||||
repo: str,
|
|
||||||
pull_number: int,
|
|
||||||
) -> list[dict]:
|
|
||||||
"""Fetch all reviews for a specific pull request.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
owner (str): Owner of the repository.
|
|
||||||
repo (str): Name of the repository.
|
|
||||||
pull_number (int): Pull request number.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[dict]: List of review dictionaries.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
requests.HTTPError: If the API request fails.
|
|
||||||
"""
|
|
||||||
url = f'{self.gitea_url}/repos/{owner}/{repo}/pulls/{pull_number}/reviews'
|
|
||||||
response = self.session.get(url)
|
|
||||||
response.raise_for_status()
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def get_review_comments(
|
|
||||||
self,
|
|
||||||
owner: str,
|
|
||||||
repo: str,
|
|
||||||
pull_number: int,
|
|
||||||
review_id: int,
|
|
||||||
) -> list[dict]:
|
|
||||||
"""Fetch all comments for a specific review.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
owner (str): Owner of the repository.
|
|
||||||
repo (str): Name of the repository.
|
|
||||||
pull_number (int): Pull request number.
|
|
||||||
review_id (int): Review ID.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[dict]: List of comment dictionaries.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
requests.HTTPError: If the API request fails.
|
|
||||||
"""
|
|
||||||
url = f'{self.gitea_url}/repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments'
|
|
||||||
response = self.session.get(url)
|
|
||||||
response.raise_for_status()
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def get_pull_request_comments(
|
|
||||||
self,
|
|
||||||
owner: str,
|
|
||||||
repo: str,
|
|
||||||
pull_number: int,
|
|
||||||
) -> list[dict]:
|
|
||||||
"""Fetch all comments for a pull request by downloading all reviews and their comments.
|
|
||||||
|
|
||||||
This method implements the flow:
|
|
||||||
1. Download all reviews of the pull request
|
|
||||||
2. Download all comments for each review
|
|
||||||
3. Return all comments from all reviews
|
|
||||||
|
|
||||||
Args:
|
|
||||||
owner (str): Owner of the repository.
|
|
||||||
repo (str): Name of the repository.
|
|
||||||
pull_number (int): Pull request number.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[dict]: List of all comment dictionaries from all reviews.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
requests.HTTPError: If the API request fails.
|
|
||||||
"""
|
|
||||||
all_comments = []
|
|
||||||
|
|
||||||
# Download all reviews of the pull request
|
|
||||||
reviews = self.get_pull_request_reviews(owner, repo, pull_number)
|
|
||||||
|
|
||||||
# Download all comments for each review
|
|
||||||
for review in reviews:
|
|
||||||
review_id = review.get('id')
|
|
||||||
if review_id:
|
|
||||||
try:
|
|
||||||
comments = self.get_review_comments(
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
pull_number,
|
|
||||||
review_id,
|
|
||||||
)
|
|
||||||
# Add review context to each comment for better debugging
|
|
||||||
for comment in comments:
|
|
||||||
comment['review_id'] = review_id
|
|
||||||
comment['review_state'] = review.get('state')
|
|
||||||
all_comments.extend(comments)
|
|
||||||
except requests.RequestException as e:
|
|
||||||
# Log the error but continue processing other reviews
|
|
||||||
logger.warning(
|
|
||||||
'Failed to get comments for review %s in PR %s: %s',
|
|
||||||
review_id,
|
|
||||||
pull_number,
|
|
||||||
e,
|
|
||||||
)
|
|
||||||
|
|
||||||
return all_comments
|
|
||||||
|
|
|
@ -69,10 +69,9 @@ class TestClaudeCodeIntegration:
|
||||||
'claude',
|
'claude',
|
||||||
'-p',
|
'-p',
|
||||||
'--output-format',
|
'--output-format',
|
||||||
'stream-json',
|
'json',
|
||||||
'--debug',
|
'--max-turns',
|
||||||
'--verbose',
|
'10',
|
||||||
'--dangerously-skip-permissions',
|
|
||||||
issue,
|
issue,
|
||||||
]
|
]
|
||||||
assert cmd == expected
|
assert cmd == expected
|
||||||
|
@ -85,10 +84,9 @@ class TestClaudeCodeIntegration:
|
||||||
'claude',
|
'claude',
|
||||||
'-p',
|
'-p',
|
||||||
'--output-format',
|
'--output-format',
|
||||||
'stream-json',
|
'json',
|
||||||
'--debug',
|
'--max-turns',
|
||||||
'--verbose',
|
'10',
|
||||||
'--dangerously-skip-permissions',
|
|
||||||
'--model',
|
'--model',
|
||||||
'claude-3-sonnet',
|
'claude-3-sonnet',
|
||||||
issue,
|
issue,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user