Commit 29a85ba4 authored by MD. SHAHIDUL ISLAM's avatar MD. SHAHIDUL ISLAM

feat: Include issue URLs in various command outputs and success messages,…

feat: Include issue URLs in various command outputs and success messages, utilizing a new `BASE_URL` for consistent generation.
parent 8415dbb4
......@@ -34,6 +34,8 @@ JIRA_USERNAME = os.environ.get("JIRA_USERNAME")
JIRA_PASSWORD = os.environ.get("JIRA_PASSWORD")
ACTIVE_PROJECT = os.environ.get("JIRA_DEFAULT_PROJECT")
BASE_URL = JIRA_SERVER.rstrip("/") if JIRA_SERVER else ""
# We use Basic Auth explicitly for this local instance.
try:
jira_client = JIRA(
......@@ -79,7 +81,7 @@ def get_my_assigned_issues() -> str:
result = ["Your Open Assigned Issues:"]
for issue in issues:
result.append(f"- [{issue.key}] {issue.fields.summary} (Status: {issue.fields.status.name}, Priority: {issue.fields.priority.name if issue.fields.priority else 'None'})")
result.append(f"- [{issue.key}] {issue.fields.summary} (Status: {issue.fields.status.name}, Priority: {issue.fields.priority.name if issue.fields.priority else 'None'})\n URL: {BASE_URL}/browse/{issue.key}")
return "\n".join(result)
except Exception as e:
return f"Error fetching issues: {str(e)}"
......@@ -96,6 +98,7 @@ def get_issue_details(issue_key: str) -> str:
details = [
f"Issue: {issue.key}",
f"URL: {BASE_URL}/browse/{issue.key}",
f"Summary: {issue.fields.summary}",
f"Type: {issue.fields.issuetype.name}",
f"Status: {issue.fields.status.name}",
......@@ -128,7 +131,7 @@ def create_issue(summary: str, description: str, project_key: str = None, issue_
'issuetype': {'name': issue_type},
}
new_issue = jira.create_issue(fields=issue_dict)
return f"Successfully created issue {new_issue.key}. URL: {JIRA_SERVER}/browse/{new_issue.key}"
return f"Successfully created issue {new_issue.key}. URL: {BASE_URL}/browse/{new_issue.key}"
except Exception as e:
return f"Error creating issue: {str(e)}"
......@@ -186,7 +189,7 @@ def create_issue_advanced(
issue_dict['timetracking'] = {'originalEstimate': original_estimate}
new_issue = jira.create_issue(fields=issue_dict)
return f"Successfully created {issue_type} {new_issue.key}. URL: {JIRA_SERVER}/browse/{new_issue.key}"
return f"Successfully created {issue_type} {new_issue.key}. URL: {BASE_URL}/browse/{new_issue.key}"
except Exception as e:
return f"Error creating advanced issue: {str(e)}"
......@@ -223,7 +226,7 @@ def create_issue_with_subtasks(summary: str, description: str, subtasks: List[st
created_subtasks.append(st_issue.key)
subtasks_str = ", ".join(created_subtasks)
return f"Successfully created {parent_issue_type} {parent_issue.key} with subtasks: {subtasks_str}. URL: {JIRA_SERVER}/browse/{parent_issue.key}"
return f"Successfully created {parent_issue_type} {parent_issue.key} with subtasks: {subtasks_str}. URL: {BASE_URL}/browse/{parent_issue.key}"
except Exception as e:
return f"Error creating {parent_issue_type} with subtasks: {str(e)}"
......@@ -265,7 +268,7 @@ def create_bulk_issues(issues_data: List[dict], project_key: str = None) -> str:
for issue_result in created_issues:
if issue_result.get('issue'):
iss = issue_result['issue']
result.append(f"- [{iss.key}] URL: {JIRA_SERVER}/browse/{iss.key}")
result.append(f"- [{iss.key}] URL: {BASE_URL}/browse/{iss.key}")
else:
result.append(f"- Failed to create issue: {issue_result.get('error')}")
......@@ -280,7 +283,7 @@ def assign_issue_to_me(issue_key: str) -> str:
try:
# Provide the username we authenticated with
jira.assign_issue(issue_key, JIRA_USERNAME)
return f"Successfully assigned issue {issue_key} to {JIRA_USERNAME}."
return f"Successfully assigned issue {issue_key} to {JIRA_USERNAME}. URL: {BASE_URL}/browse/{issue_key}"
except Exception as e:
return f"Error assigning issue {issue_key}: {str(e)}"
......@@ -307,7 +310,7 @@ def transition_issue(issue_key: str, transition_name: str) -> str:
# Execute the transition
jira.transition_issue(issue_key, transition_id)
return f"Successfully transitioned issue {issue_key} to '{transition_name}'."
return f"Successfully transitioned issue {issue_key} to '{transition_name}'. URL: {BASE_URL}/browse/{issue_key}"
except Exception as e:
return f"Error transitioning issue {issue_key}: {str(e)}"
......@@ -327,7 +330,7 @@ def search_issues(jql_query: str) -> str:
for issue in issues:
assignee = issue.fields.assignee.displayName if issue.fields.assignee else "Unassigned"
priority = issue.fields.priority.name if getattr(issue.fields, 'priority', None) else 'None'
result.append(f"- [{issue.key}] {issue.fields.summary} (Status: {issue.fields.status.name}, Assignee: {assignee}, Priority: {priority})")
result.append(f"- [{issue.key}] {issue.fields.summary} (Status: {issue.fields.status.name}, Assignee: {assignee}, Priority: {priority})\n URL: {BASE_URL}/browse/{issue.key}")
return "\n".join(result)
except Exception as e:
return f"Error searching issues: {str(e)}"
......@@ -354,7 +357,7 @@ def add_comment_to_issue(issue_key: str, comment: str) -> str:
jira = _get_jira()
try:
jira.add_comment(issue_key, comment)
return f"Successfully added comment to {issue_key}."
return f"Successfully added comment to {issue_key}. URL: {BASE_URL}/browse/{issue_key}"
except Exception as e:
return f"Error adding comment to {issue_key}: {str(e)}"
......@@ -382,7 +385,7 @@ def log_work_on_issue(issue_key: str, time_spent: str) -> str:
jira = _get_jira()
try:
jira.add_worklog(issue_key, timeSpent=time_spent)
return f"Successfully logged {time_spent} of work on {issue_key}."
return f"Successfully logged {time_spent} of work on {issue_key}. URL: {BASE_URL}/browse/{issue_key}"
except Exception as e:
return f"Error logging work on {issue_key}: {str(e)}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment