fix: Resolve label assignment issue using dedicated Gitea API endpoint

- Update ProjectManager.set_issue_state() to use /issues/{id}/labels endpoint with PUT method
- Update ProjectManager.set_issue_priority() to use dedicated labels endpoint
- Update IssueWriter.update_labels() to use dedicated labels endpoint for reliability
- Fix API format incompatibility where issue PATCH endpoint was ignoring label updates
- Label assignment now works correctly with proper state and priority management
- Issues will now properly appear in correct Kanban columns based on status labels

Root cause: Gitea API issue PATCH endpoint silently ignores label updates, but the
dedicated labels endpoint (/issues/{id}/labels) with PUT method works correctly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-25 00:31:37 +02:00
parent 8fa6325108
commit 64286b138d
2 changed files with 56 additions and 7 deletions

View File

@@ -90,8 +90,50 @@ class IssueWriter:
return self.update_issue(issue_number, {'milestone': None})
def update_labels(self, issue_number: int, labels: list) -> Dict[str, Any]:
"""Update issue labels completely."""
return self.update_issue(issue_number, {'labels': labels})
"""Update issue labels completely using dedicated labels endpoint."""
if not self.auth_token:
raise IssueError("Authentication token required for label updates")
# Use the dedicated labels endpoint which works more reliably
url = f"{self.config.issues_api_url}/{issue_number}/labels"
try:
# Use PUT to replace all labels
curl_cmd = [
'curl', '-s', '-X', 'PUT',
'-H', 'Content-Type: application/json',
'-H', f'Authorization: token {self.auth_token}',
'-d', json.dumps({'labels': labels}),
url
]
result = subprocess.run(
curl_cmd,
stdout=PIPE,
stderr=PIPE,
universal_newlines=True,
check=True
)
if result.returncode != 0:
raise IssueError(f"Failed to update labels for issue #{issue_number}: {result.stderr}")
# Parse the response - labels endpoint returns array of labels
if result.stdout.strip():
response_data = json.loads(result.stdout)
# Convert labels response back to issue format for consistency
return {
'number': issue_number,
'labels': response_data if isinstance(response_data, list) else []
}
else:
return {'number': issue_number, 'labels': []}
except subprocess.CalledProcessError as e:
raise IssueError(f"Failed to update labels for issue #{issue_number}: {e}")
except json.JSONDecodeError as e:
raise IssueError(f"Failed to parse labels response: {e}")
def add_labels(self, issue_number: int, new_labels: list) -> Dict[str, Any]:
"""Add labels to issue (preserving existing labels)."""