feat: add Asana ticket detection to ticket compliance check#2430
feat: add Asana ticket detection to ticket compliance check#2430Oxygen56 wants to merge 6 commits into
Conversation
Review Summary by QodoAdd Asana ticket detection and fix indentation normalization
WalkthroughsDescription• Add Asana ticket detection to PR compliance check - Supports full URLs and ASANA-123456789 shorthand format - Asana tickets included in related tickets list • Fix indentation character preservation in /improve suggestions - Handle negative delta_spaces with dedent operation - Normalize tabs/spaces to match original file's indentation Diagramflowchart LR
A["PR Description & Branch"] -->|find_asana_tickets| B["Asana URLs Detected"]
B -->|extract_tickets| C["Merged Ticket List"]
C -->|Asana URLs| D["Placeholder Content"]
E["Code Suggestions"] -->|dedent_code| F["Normalize Indentation"]
F -->|Detect char| G["Tab or Space"]
G -->|Apply| H["Corrected Code"]
File Changes1. pr_agent/tools/pr_code_suggestions.py
|
Code Review by Qodo
Context used✅ Tickets:
🎫 Add Support for Asana Ticket Provider 1.
|
|
Hey @Oxygen56, Can you please add tests to validate the new functionality? 🙏 |
|
Code review by qodo was updated up to the latest commit a2bf77a |
|
Code review by qodo was updated up to the latest commit a0c62b4 |
|
感谢所有 review 意见,我已在最新提交中处理了以下问题: Bug 修复:
规范/安全修复:
测试补充:
|
The dedent_code method only adjusted indentation when delta_spaces > 0 and never normalized the indentation character. This caused /improve to replace tabs with spaces in Go, Makefile, and other tab-indented codebases. Changes: - Handle delta_spaces < 0 case with dedent (not just > 0) - Normalize all suggestion lines to use the original file's indentation character (tab or space), auto-detected from the existing code Fixes The-PR-Agent#1858 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds support for detecting Asana task references in PR descriptions and branch names. Supports both full URLs and ASANA-123456789 shorthand format. - find_asana_tickets() extracts Asana task URLs from text - Asana tickets are included in the compliance check's related tickets - Graceful handling: Asana URLs are shown with a placeholder body since they cannot be fetched via the GitHub API Fixes The-PR-Agent#2002 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Use ticket_url instead of url (templates access ticket.ticket_url) - Add labels field (templates access ticket.labels under StrictUndefined) - Add ticket_id field for consistency with GitHub ticket entries
- Replace textwrap.dedent() with exact -delta_spaces removal to avoid stripping too much indentation when lines have varying levels - Preserve remainder spaces when converting spaces to tabs (e.g. 6 spaces → 1 tab + 2 spaces instead of silently dropping 2)
…check - Covers full Asana URLs, shorthand ASANA- prefix, case-insensitivity - Tests deduplication, sorting, empty input, and mixed PR description content - Validates GitHub URLs are not misidentified as Asana tickets
- Use compiled Asana patterns (_ASANA_TASK_URL_PATTERN, _ASANA_TASK_SHORT_PATTERN) in find_asana_tickets() instead of inline regex (CodeQL unused-variable, comments The-PR-Agent#5/The-PR-Agent#6). - Add re.IGNORECASE flag to _ASANA_TASK_SHORT_PATTERN for proper case-insensitive matching. - Replace substring match ('app.asana.com' in ticket) with prefix check (ticket.startswith()) to fix CodeQL URL sanitization warning (comment The-PR-Agent#4). - Reserve at least one slot for Asana tickets during truncation when there are 3+ GitHub/branch tickets (comment The-PR-Agent#8). - Dedent only actual leading whitespace instead of blindly slicing dline[remove_count:] to avoid deleting real code on lines with less indentation (comments The-PR-Agent#3/The-PR-Agent#9). - Remove unused 'import pytest' from test file (comments The-PR-Agent#10/The-PR-Agent#20). - Add test_shorthand_mixed_case_asana and test_shorthand_respects_word_boundary test cases.
2921c2b to
3ce5450
Compare
|
Code review by qodo was updated up to the latest commit 3ce5450 |
|
Hey @naorpeled, thanks for the review! Tests have been added — there are now 12 test cases in
The test file was added in commit |
What
Fixes #2002 — Adds Asana task references detection to the PR ticket compliance check.
Problem
The ticket compliance check only detected GitHub issues and JIRA tickets. Teams using Asana had no automated ticket validation.
Solution
Adds
find_asana_tickets()that detects:https://app.asana.com/0/{project_id}/{task_id}ASANA-123456789012Asana references are included in the compliance check's related tickets alongside GitHub and JIRA references.