refactor: Factor out Gitea interfacing into clean facade pattern
- Create new gitea/ package with clean API facade - Establish proper separation of concerns: tddai uses gitea, not vice versa - Replace duplicate curl+subprocess patterns with unified HTTP client - Add rich domain models with properties (issue.priority, issue.status) - Maintain full backwards compatibility in tddai modules - Reduce code complexity: -373 lines, +151 lines (net -222 lines) - Improve testability and maintainability through clean interfaces Architecture: - gitea.client.GiteaClient - main facade with sub-clients - gitea.api_client - high-level API with model conversion - gitea.http_client - low-level HTTP operations - gitea.models - rich domain objects (Issue, Milestone, Label) - gitea.config - gitea-specific configuration - gitea.exceptions - clean exception hierarchy 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
26
tddai_cli.py
26
tddai_cli.py
@@ -691,12 +691,8 @@ def issue_index(format_type="tsv", sort_by="number", filter_state=None, filter_p
|
||||
"""
|
||||
try:
|
||||
fetcher = IssueFetcher()
|
||||
project_mgr = ProjectManager()
|
||||
from tddai.config import get_config
|
||||
import json
|
||||
|
||||
config = get_config()
|
||||
|
||||
issues = fetcher.fetch_issues()
|
||||
if not issues:
|
||||
return
|
||||
@@ -704,30 +700,16 @@ def issue_index(format_type="tsv", sort_by="number", filter_state=None, filter_p
|
||||
# Collect full issue data with additional fields
|
||||
issue_data = []
|
||||
for issue in issues:
|
||||
# Get priority and state from labels
|
||||
priority = "none"
|
||||
state = "none"
|
||||
try:
|
||||
# Use ProjectManager's API call method
|
||||
issue_url = f"{config.issues_api_url}/{issue.number}"
|
||||
detailed_issue = project_mgr._make_api_call('GET', issue_url)
|
||||
labels = detailed_issue.get('labels', [])
|
||||
priority_labels = [l['name'] for l in labels if l['name'].startswith('priority:')]
|
||||
state_labels = [l['name'] for l in labels if l['name'].startswith('status:')]
|
||||
|
||||
if priority_labels:
|
||||
priority = priority_labels[0].replace('priority:', '')
|
||||
if state_labels:
|
||||
state = state_labels[0].replace('status:', '')
|
||||
except:
|
||||
pass # Keep defaults if API call fails
|
||||
# Get priority and state from labels - now using the rich issue model
|
||||
priority = issue.priority or "none"
|
||||
status = issue.status or "none"
|
||||
|
||||
issue_info = {
|
||||
'number': issue.number,
|
||||
'title': issue.title.replace('\t', ' ').replace('\n', ' '), # Clean for TSV
|
||||
'priority': priority,
|
||||
'state': issue.state, # open/closed from basic data
|
||||
'status': state, # detailed status from labels
|
||||
'status': status, # detailed status from labels
|
||||
'created': issue.created_at.strftime('%Y-%m-%d'),
|
||||
'updated': issue.updated_at.strftime('%Y-%m-%d')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user