Skip to content

Commit 2f7b88e

Browse files
committed
EX-329: fix and update jira logic
1 parent dc6a403 commit 2f7b88e

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

src/code_review_agent/cli.py

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def filter_test_files(
7777

7878
return files_for_review_map
7979

80-
app = typer.Typer(add_completion=False)
80+
app = typer.Typer(add_completion=False, invoke_without_command=True)
8181

8282

8383
def setup_logging(trace_mode: bool):
@@ -119,19 +119,9 @@ def load_config(repo_path: str) -> dict:
119119
POSSIBLE_FOCUS_AREAS = list(IssueType.__args__)
120120

121121

122-
@app.command()
123-
def review(
124-
repo_path: Annotated[str, typer.Option("--repo-path", help="Path to the local Git repository.")] = ".",
125-
base_ref: Annotated[str, typer.Option(help="The base commit/ref to compare against.")] = "HEAD~1",
126-
head_ref: Annotated[str, typer.Option(help="The commit hash or ref to review.")] = "HEAD",
127-
staged: Annotated[bool, typer.Option(help="Review only staged files instead of a commit range.")] = False,
128-
focus_from_cli: Annotated[Optional[List[str]], typer.Option(
129-
"-f", "--focus",
130-
help=f"Areas of focus. Can be used multiple times. Possible values: {', '.join(POSSIBLE_FOCUS_AREAS)}"
131-
)] = None,
132-
trace: Annotated[bool, typer.Option(
133-
"--trace", help="Enable detailed debug logging to the console."
134-
)] = False,
122+
def run_review_logic(
123+
repo_path: str, base_ref: str, head_ref: str, staged: bool,
124+
focus_from_cli: Optional[List[str]], trace: bool
135125
):
136126
"""
137127
Performs an AI-powered, context-aware code review using an iterative context-building approach.
@@ -344,11 +334,29 @@ def review(
344334
else:
345335
logging.info(f"\nFound a total of {len(all_issues)} issue(s).")
346336

347-
def main():
348-
app()
349337

350-
if __name__ == "__main__":
351-
main()
338+
@app.callback()
339+
def main_callback(
340+
ctx: typer.Context,
341+
repo_path: Annotated[str, typer.Option("--repo-path")] = ".",
342+
base_ref: Annotated[str, typer.Option()] = "HEAD~1",
343+
head_ref: Annotated[str, typer.Option()] = "HEAD",
344+
staged: Annotated[bool, typer.Option()] = False,
345+
focus_from_cli: Annotated[Optional[List[str]], typer.Option("-f", "--focus")] = None,
346+
trace: Annotated[bool, typer.Option("--trace")] = False,
347+
):
348+
"""
349+
AI Code Review Agent.
350+
If no subcommand (like 'assess') is given, this will run the code review by default.
351+
"""
352+
if ctx.invoked_subcommand is not None:
353+
return
354+
355+
typer.echo("Running default command: review")
356+
run_review_logic(
357+
repo_path=repo_path, base_ref=base_ref, head_ref=head_ref, staged=staged,
358+
focus_from_cli=focus_from_cli, trace=trace
359+
)
352360

353361
@app.command()
354362
def assess(
@@ -399,4 +407,11 @@ def assess(
399407
f"/!\\ The code changes have a **{relevance.score}%** relevance score to this task.\n\n"
400408
f"**Justification:** {relevance.justification}"
401409
)
402-
jira_client.add_comment(task_id, comment_body)
410+
jira_client.add_comment(task_id, comment_body)
411+
412+
413+
def main():
414+
app()
415+
416+
if __name__ == "__main__":
417+
main()

src/code_review_agent/jira_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _get_jira_client():
2727

2828
def find_task_id(text: str) -> str | None:
2929
"""Finds a Jira-like task ID (e.g., ABC-123) in a string."""
30-
match = re.search(r'\b([A-Z]{2,4}-\d+)\b', text, re.IGNORECASE)
30+
match = re.search(r'(?<![A-Z\d-])([A-Z]{2,4}-\d+)', text, re.IGNORECASE)
3131
return match.group(0).upper() if match else None
3232

3333
def get_task_details(task_id: str) -> dict | None:

0 commit comments

Comments
 (0)