Compare commits
No commits in common. "54cddfde0ba5181dc063434d80ff04b2eb845dbe" and "04b3baaba266d332ddf86a4423853cf129510f8a" have entirely different histories.
54cddfde0b
...
04b3baaba2
|
@ -103,11 +103,7 @@ class RepositoryConfig:
|
||||||
class IssueResolution:
|
class IssueResolution:
|
||||||
success: bool
|
success: bool
|
||||||
pull_request_url: str | None = None
|
pull_request_url: str | None = None
|
||||||
pull_request_id: int | None = None
|
pull_request_id: str | None = None
|
||||||
|
|
||||||
def __post_init__(self):
|
|
||||||
assert self.pull_request_id is None or isinstance(self.pull_request_id, int)
|
|
||||||
assert self.pull_request_url is None or isinstance(self.pull_request_url, str)
|
|
||||||
|
|
||||||
|
|
||||||
def generate_branch_name(issue_number: str, issue_title: str) -> str:
|
def generate_branch_name(issue_number: str, issue_title: str) -> str:
|
||||||
|
@ -287,8 +283,8 @@ def push_changes(
|
||||||
# Extract PR number and URL if available
|
# Extract PR number and URL if available
|
||||||
return IssueResolution(
|
return IssueResolution(
|
||||||
True,
|
True,
|
||||||
|
str(pr_response.get('number')),
|
||||||
pr_response.get('html_url'),
|
pr_response.get('html_url'),
|
||||||
int(pr_response.get('number')),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -506,21 +502,21 @@ def solve_issues_in_repository(
|
||||||
title = issue.get('title', f'Issue {issue_number}')
|
title = issue.get('title', f'Issue {issue_number}')
|
||||||
if seen_issues_db.has_seen(issue_url):
|
if seen_issues_db.has_seen(issue_url):
|
||||||
logger.info('Skipping already processed issue #%s: %s', issue_number, title)
|
logger.info('Skipping already processed issue #%s: %s', issue_number, title)
|
||||||
else:
|
continue
|
||||||
branch_name = generate_branch_name(issue_number, title)
|
|
||||||
with tempfile.TemporaryDirectory() as repository_path:
|
|
||||||
issue_resolution = solve_issue_in_repository(
|
|
||||||
repository_config,
|
|
||||||
Path(repository_path),
|
|
||||||
branch_name,
|
|
||||||
title,
|
|
||||||
issue_description,
|
|
||||||
issue_number,
|
|
||||||
client,
|
|
||||||
)
|
|
||||||
|
|
||||||
# TODO: PR comment handling disabled for now due to missing functionality
|
branch_name = generate_branch_name(issue_number, title)
|
||||||
if False:
|
with tempfile.TemporaryDirectory() as repository_path:
|
||||||
|
issue_resolution = solve_issue_in_repository(
|
||||||
|
repository_config,
|
||||||
|
Path(repository_path),
|
||||||
|
branch_name,
|
||||||
|
title,
|
||||||
|
issue_description,
|
||||||
|
issue_number,
|
||||||
|
client,
|
||||||
|
)
|
||||||
|
|
||||||
|
if issue_resolution.success:
|
||||||
# Handle unresolved pull request comments
|
# Handle unresolved pull request comments
|
||||||
handle_pr_comments(
|
handle_pr_comments(
|
||||||
repository_config,
|
repository_config,
|
||||||
|
@ -546,7 +542,7 @@ def solve_issues_in_repository(
|
||||||
|
|
||||||
def handle_pr_comments(
|
def handle_pr_comments(
|
||||||
repository_config,
|
repository_config,
|
||||||
pr_number: int,
|
pr_number,
|
||||||
branch_name,
|
branch_name,
|
||||||
repository_path,
|
repository_path,
|
||||||
client,
|
client,
|
||||||
|
|
|
@ -167,7 +167,7 @@ class GiteaClient:
|
||||||
|
|
||||||
response = self.session.post(url, json=json_data)
|
response = self.session.post(url, json=json_data)
|
||||||
# If a pull request for this head/base already exists, return it instead of crashing
|
# If a pull request for this head/base already exists, return it instead of crashing
|
||||||
if response.status_code == 409:
|
if response.status_code == 422:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'Pull request already exists for head %s and base %s', head, base,
|
'Pull request already exists for head %s and base %s', head, base,
|
||||||
)
|
)
|
||||||
|
@ -183,6 +183,20 @@ class GiteaClient:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
def get_pull_request_comments(
|
||||||
|
self,
|
||||||
|
owner: str,
|
||||||
|
repo: str,
|
||||||
|
pr_number: str,
|
||||||
|
) -> list[dict]:
|
||||||
|
"""
|
||||||
|
Fetch comments for a pull request.
|
||||||
|
"""
|
||||||
|
url = f'{self.gitea_url}/repos/{owner}/{repo}/pulls/{pr_number}/comments'
|
||||||
|
response = self.session.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
return response.json()
|
||||||
|
|
||||||
def get_pull_requests(
|
def get_pull_requests(
|
||||||
self,
|
self,
|
||||||
owner: str,
|
owner: str,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user