refactor: extract focused clients from GiteaClient (Slices 1-6)
- Create gitea/issues_client.py with IssuesClient class (9 methods) - Create gitea/prs_client.py with PullRequestsClient class (17 methods) - Create gitea/files_client.py with FilesClient class (4 methods) - Create gitea/notifications_client.py with NotificationsClient class (2 methods) - Create gitea/repos_client.py with ReposClient class (2 methods) - Create gitea/__init__.py to export all client classes - Remove delegation methods from GiteaClient (now ~70 lines) - Update all callers to use sub-clients (client.issues, client.prs, etc.) - Update test files to mock sub-client attributes GiteaClient is now a facade that provides access to focused sub-clients: - repos: Repository operations (ReposClient) - issues: Issue operations (IssuesClient) - prs: Pull request operations (PullRequestsClient) - files: File and git ref operations (FilesClient) - notifications: Notification operations (NotificationsClient) Refs: #godclass-refactor
This commit is contained in:
+13
-5
@@ -90,7 +90,9 @@ class AgentOrchestrator:
|
||||
f"Polling unread notifications since: {last_checked or 'beginning'}"
|
||||
)
|
||||
|
||||
notifications = self._client.list_unread_notifications(since=last_checked)
|
||||
notifications = self._client.notifications.list_unread_notifications(
|
||||
since=last_checked
|
||||
)
|
||||
|
||||
if not notifications:
|
||||
logger.info("No new notifications found.")
|
||||
@@ -165,7 +167,9 @@ class AgentOrchestrator:
|
||||
f"Skipping notification {notification_id} for {repo_full_name}#{task_number}. Reason: {reason}"
|
||||
)
|
||||
if notification_id is not None:
|
||||
self._client.mark_notification_as_read(notification_id)
|
||||
self._client.notifications.mark_notification_as_read(
|
||||
notification_id
|
||||
)
|
||||
logger.info(
|
||||
f"Marked skipped Gitea notification thread {notification_id} as read."
|
||||
)
|
||||
@@ -174,7 +178,7 @@ class AgentOrchestrator:
|
||||
# Route based on decided action
|
||||
if notification_tools.action == "PROCESS_ISSUE":
|
||||
try:
|
||||
issue = self._client.get_issue(owner, repo_name, task_number)
|
||||
issue = self._client.issues.get_issue(owner, repo_name, task_number)
|
||||
if issue.repository is None:
|
||||
issue = issue.model_copy(
|
||||
update={"repository": RepositoryModel(**repo_info)}
|
||||
@@ -195,7 +199,9 @@ class AgentOrchestrator:
|
||||
)
|
||||
elif notification_tools.action == "PROCESS_PR":
|
||||
try:
|
||||
pr = self._client.get_pull_request(owner, repo_name, task_number)
|
||||
pr = self._client.prs.get_pull_request(
|
||||
owner, repo_name, task_number
|
||||
)
|
||||
if pr.repository is None:
|
||||
pr = pr.model_copy(
|
||||
update={"repository": RepositoryModel(**repo_info)}
|
||||
@@ -252,7 +258,9 @@ class AgentOrchestrator:
|
||||
f"Completed {item.task_type} #{item.task_number}: {result[:200]}"
|
||||
)
|
||||
if item.notification_id is not None:
|
||||
self._client.mark_notification_as_read(item.notification_id)
|
||||
self._client.notifications.mark_notification_as_read(
|
||||
item.notification_id
|
||||
)
|
||||
logger.info(
|
||||
f"Marked Gitea notification thread {item.notification_id} as read."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user